Bug 1956726 - Migrate histograms to use Glean APIs in security/manager/ssl/, r=chutten.

Differential Revision: https://phabricator.services.mozilla.com/D244171
This commit is contained in:
Florian Quèze
2025-04-03 17:30:11 +00:00
parent dde76c472e
commit 44055d9253
7 changed files with 97 additions and 23 deletions

View File

@@ -21,7 +21,7 @@
#include "nsNativeCharsetUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/SharedLibrary.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/SecurityManagerSslMetrics.h"
#include "nsAuthGSSAPI.h"
@@ -343,10 +343,10 @@ nsAuthGSSAPI::Init(const nsACString& serviceName, uint32_t serviceFlags,
static bool sTelemetrySent = false;
if (!sTelemetrySent) {
mozilla::Telemetry::Accumulate(mozilla::Telemetry::NTLM_MODULE_USED_2,
serviceFlags & nsIAuthModule::REQ_PROXY_AUTH
? NTLM_MODULE_KERBEROS_PROXY
: NTLM_MODULE_KERBEROS_DIRECT);
mozilla::glean::security::ntlm_module_used.AccumulateSingleSample(
serviceFlags & nsIAuthModule::REQ_PROXY_AUTH
? NTLM_MODULE_KERBEROS_PROXY
: NTLM_MODULE_KERBEROS_DIRECT);
sTelemetrySent = true;
}

View File

@@ -22,7 +22,7 @@
#include "nsServiceManagerUtils.h"
#include "nsCOMPtr.h"
#include "nsICryptoHash.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/SecurityManagerSslMetrics.h"
#include <windows.h>
@@ -256,10 +256,10 @@ nsAuthSSPI::Init(const nsACString& aServiceName, uint32_t aServiceFlags,
static bool sTelemetrySent = false;
if (!sTelemetrySent) {
mozilla::Telemetry::Accumulate(mozilla::Telemetry::NTLM_MODULE_USED_2,
aServiceFlags & nsIAuthModule::REQ_PROXY_AUTH
? NTLM_MODULE_WIN_API_PROXY
: NTLM_MODULE_WIN_API_DIRECT);
mozilla::glean::security::ntlm_module_used.AccumulateSingleSample(
aServiceFlags & nsIAuthModule::REQ_PROXY_AUTH
? NTLM_MODULE_WIN_API_PROXY
: NTLM_MODULE_WIN_API_DIRECT);
sTelemetrySent = true;
}

View File

@@ -10,7 +10,7 @@
#include "prenv.h"
#include "plbase64.h"
#include "prerror.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/SecurityManagerSslMetrics.h"
#include <stdlib.h>
#include <sys/wait.h>
@@ -190,10 +190,10 @@ nsAuthSambaNTLM::Init(const nsACString& serviceName, uint32_t serviceFlags,
static bool sTelemetrySent = false;
if (!sTelemetrySent) {
mozilla::Telemetry::Accumulate(mozilla::Telemetry::NTLM_MODULE_USED_2,
serviceFlags & nsIAuthModule::REQ_PROXY_AUTH
? NTLM_MODULE_SAMBA_AUTH_PROXY
: NTLM_MODULE_SAMBA_AUTH_DIRECT);
mozilla::glean::security::ntlm_module_used.AccumulateSingleSample(
serviceFlags & nsIAuthModule::REQ_PROXY_AUTH
? NTLM_MODULE_SAMBA_AUTH_PROXY
: NTLM_MODULE_SAMBA_AUTH_DIRECT);
sTelemetrySent = true;
}

View File

@@ -16,6 +16,7 @@
#include "cosec.h"
#include "mozilla/Base64.h"
#include "mozilla/Casting.h"
#include "mozilla/glean/SecurityManagerSslMetrics.h"
#include "mozilla/Logging.h"
#include "mozilla/Preferences.h"
#include "mozilla/RefPtr.h"
@@ -1352,7 +1353,8 @@ nsresult OpenSignedAppFile(
bucket += aPolicy.ProcessPK7();
bucket += !pkcs7CertDER.IsEmpty();
bucket += pk7Verified;
Telemetry::Accumulate(Telemetry::ADDON_SIGNATURE_VERIFICATION_STATUS, bucket);
glean::security::addon_signature_verification_status.AccumulateSingleSample(
bucket);
if ((aPolicy.PK7Required() && !pk7Verified) ||
(aPolicy.COSERequired() && !coseVerified)) {

View File

@@ -15,6 +15,7 @@
#include "mozilla/Base64.h"
#include "mozilla/Logging.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/glean/SecurityManagerSslMetrics.h"
#include "nsCOMPtr.h"
#include "nsPromiseFlatString.h"
#include "nsSecurityHeaderParser.h"
@@ -125,7 +126,8 @@ nsresult VerifyContentSignatureTask::CalculateResult() {
if (certFingerprint.Length() > 0) {
Telemetry::AccumulateCategoricalKeyed(certFingerprint, errorLabel);
}
Accumulate(Telemetry::CONTENT_SIGNATURE_VERIFICATION_STATUS, errorValue);
glean::security::content_signature_verification_status
.AccumulateSingleSample(errorValue);
if (rv == NS_ERROR_INVALID_SIGNATURE) {
return NS_OK;
}
@@ -133,7 +135,8 @@ nsresult VerifyContentSignatureTask::CalculateResult() {
}
mSignatureVerified = true;
Accumulate(Telemetry::CONTENT_SIGNATURE_VERIFICATION_STATUS, 0);
glean::security::content_signature_verification_status.AccumulateSingleSample(
0);
return NS_OK;
}

View File

@@ -380,6 +380,75 @@ security:
expires: never
telemetry_mirror: SECURITY_CLIENT_AUTH_CERT_USAGE
addon_signature_verification_status:
type: custom_distribution
description: >
Records the result of App Signature Verification. See the comments in
OpenSignedAppFile.
This metric was generated to correspond to the Legacy Telemetry enumerated
histogram ADDON_SIGNATURE_VERIFICATION_STATUS.
range_min: 0
range_max: 32
bucket_count: 33
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1771523
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1771523
notification_emails:
- seceng-telemetry@mozilla.com
expires: never
telemetry_mirror: ADDON_SIGNATURE_VERIFICATION_STATUS
content_signature_verification_status:
type: custom_distribution
description: >
What was the result of the content signature verification? 0=valid,
1=invalid, 2=noCertChain, 3=createContextFailedWithOtherError,
4=expiredCert, 5=certNotValidYet, 6=buildCertChainFailed,
7=eeCertForWrongHost, 8=extractKeyError, 9=vfyContextError
This metric was generated to correspond to the Legacy Telemetry enumerated
histogram CONTENT_SIGNATURE_VERIFICATION_STATUS.
range_min: 0
range_max: 20
bucket_count: 21
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1258647
- https://bugzilla.mozilla.org/show_bug.cgi?id=1862062
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1258647
- https://bugzilla.mozilla.org/show_bug.cgi?id=1862062
notification_emails:
- seceng-telemetry@mozilla.com
expires: never
telemetry_mirror: CONTENT_SIGNATURE_VERIFICATION_STATUS
ntlm_module_used:
type: custom_distribution
description: >
The module used for the NTLM protocol (Windows_API, Kerberos, Samba_auth
or Generic) and whether or not the authentication was used to connect to a
proxy server. This data is collected only once per session (at first NTLM
authentification) ; fixed version.
This metric was generated to correspond to the Legacy Telemetry enumerated
histogram NTLM_MODULE_USED_2.
range_min: 0
range_max: 8
bucket_count: 9
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1956726
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1956726
notification_emails:
- seceng-telemetry@mozilla.com
expires: never
telemetry_mirror: NTLM_MODULE_USED_2
cert:
ev_status:
type: custom_distribution

View File

@@ -19,7 +19,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/SecurityManagerSslMetrics.h"
#include "nsCOMPtr.h"
#include "nsComponentManagerUtils.h"
#include "nsICryptoHash.h"
@@ -892,10 +892,10 @@ nsNTLMAuthModule::Init(const nsACString& serviceName, uint32_t serviceFlags,
static bool sTelemetrySent = false;
if (!sTelemetrySent) {
mozilla::Telemetry::Accumulate(mozilla::Telemetry::NTLM_MODULE_USED_2,
serviceFlags & nsIAuthModule::REQ_PROXY_AUTH
? NTLM_MODULE_GENERIC_PROXY
: NTLM_MODULE_GENERIC_DIRECT);
mozilla::glean::security::ntlm_module_used.AccumulateSingleSample(
serviceFlags & nsIAuthModule::REQ_PROXY_AUTH
? NTLM_MODULE_GENERIC_PROXY
: NTLM_MODULE_GENERIC_DIRECT);
sTelemetrySent = true;
}