Bug 1960567 - Migrate histograms to use Glean APIs in toolkit/components/reputationservice/, r=chutten.

Differential Revision: https://phabricator.services.mozilla.com/D255545
This commit is contained in:
Florian Quèze 2025-07-08 13:35:09 +00:00 committed by fqueze@mozilla.com
parent 88cd22ecaf
commit b3c6b1d068
4 changed files with 43 additions and 14 deletions

View file

@ -1882,8 +1882,9 @@ nsresult PendingLookup::OnStopRequestInternal(nsIRequest* aRequest,
mozilla::glean::application_reputation::server_verdict.AccumulateSingleSample( mozilla::glean::application_reputation::server_verdict.AccumulateSingleSample(
std::min<uint32_t>(response.verdict(), 7)); std::min<uint32_t>(response.verdict(), 7));
const char* ext = GetFileExt(mFileName); const char* ext = GetFileExt(mFileName);
AccumulateCategoricalKeyed(nsCString(ext), VerdictToLabel(std::min<uint32_t>( mozilla::glean::application_reputation::server_verdict_2.Get(
response.verdict(), 7))); nsCString(ext),
VerdictToLabel(std::min<uint32_t>(response.verdict(), 7)));
switch (response.verdict()) { switch (response.verdict()) {
case safe_browsing::ClientDownloadResponse::DANGEROUS: case safe_browsing::ClientDownloadResponse::DANGEROUS:
aVerdict = nsIApplicationReputationService::VERDICT_DANGEROUS; aVerdict = nsIApplicationReputationService::VERDICT_DANGEROUS;

View file

@ -7,8 +7,6 @@
#include "chrome/common/safe_browsing/csd.pb.h" #include "chrome/common/safe_browsing/csd.pb.h"
using ServerLabel = mozilla::glean::application_reputation::Server2Label; using ServerLabel = mozilla::glean::application_reputation::Server2Label;
using ServerVerdictLabel =
mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_SERVER_VERDICT_2;
struct NSErrorTelemetryResult { struct NSErrorTelemetryResult {
nsresult mValue; nsresult mValue;
@ -174,20 +172,19 @@ ServerLabel HTTPStatusToLabel(uint32_t aStatus) {
} }
} }
mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_SERVER_VERDICT_2 nsLiteralCString VerdictToLabel(uint32_t aVerdict) {
VerdictToLabel(uint32_t aVerdict) {
switch (aVerdict) { switch (aVerdict) {
case safe_browsing::ClientDownloadResponse::DANGEROUS: case safe_browsing::ClientDownloadResponse::DANGEROUS:
return ServerVerdictLabel::Dangerous; return "Dangerous"_ns;
case safe_browsing::ClientDownloadResponse::DANGEROUS_HOST: case safe_browsing::ClientDownloadResponse::DANGEROUS_HOST:
return ServerVerdictLabel::DangerousHost; return "DangerousHost"_ns;
case safe_browsing::ClientDownloadResponse::POTENTIALLY_UNWANTED: case safe_browsing::ClientDownloadResponse::POTENTIALLY_UNWANTED:
return ServerVerdictLabel::PotentiallyUnwanted; return "PotentiallyUnwanted"_ns;
case safe_browsing::ClientDownloadResponse::UNCOMMON: case safe_browsing::ClientDownloadResponse::UNCOMMON:
return ServerVerdictLabel::Uncommon; return "Uncommon"_ns;
case safe_browsing::ClientDownloadResponse::UNKNOWN: case safe_browsing::ClientDownloadResponse::UNKNOWN:
return ServerVerdictLabel::Unknown; return "Unknown"_ns;
default: default:
return ServerVerdictLabel::Safe; return "Safe"_ns;
} }
} }

View file

@ -40,7 +40,6 @@ mozilla::glean::application_reputation::Server2Label HTTPStatusToLabel(
/** /**
* Convert verdict type to telemetry labels * Convert verdict type to telemetry labels
*/ */
mozilla::Telemetry::LABELS_APPLICATION_REPUTATION_SERVER_VERDICT_2 nsLiteralCString VerdictToLabel(uint32_t aVerdict);
VerdictToLabel(uint32_t aVerdict);
#endif // ApplicationReputationTelemetryUtils_h__ #endif // ApplicationReputationTelemetryUtils_h__

View file

@ -199,6 +199,38 @@ application_reputation:
expires: never expires: never
telemetry_mirror: APPLICATION_REPUTATION_SERVER_VERDICT telemetry_mirror: APPLICATION_REPUTATION_SERVER_VERDICT
server_verdict_2:
type: dual_labeled_counter
description: >
Application reputation remote verdict, keyed by file extension
This metric was generated to correspond to the Legacy Telemetry
categorical histogram APPLICATION_REPUTATION_SERVER_VERDICT_2.
dual_labels:
key:
description: File extension.
category:
labels:
- Safe
- Dangerous
- Uncommon
- PotentiallyUnwanted
- DangerousHost
- Unknown
description: Labels of the keyed categorical legacy telemetry histogram
APPLICATION_REPUTATION_SERVER_VERDICT_2.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1501974
- https://bugzilla.mozilla.org/show_bug.cgi?id=1589042
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1501974
- https://bugzilla.mozilla.org/show_bug.cgi?id=1589042
notification_emails:
- dlee@mozilla.com
- safebrowsing-telemetry@mozilla.org
expires: never
telemetry_mirror: APPLICATION_REPUTATION_SERVER_VERDICT_2
remote_lookup_response_time: remote_lookup_response_time:
type: timing_distribution type: timing_distribution
description: > description: >