diff --git a/dom/security/ReferrerInfo.cpp b/dom/security/ReferrerInfo.cpp index e816d3af4272..a85d3b88f485 100644 --- a/dom/security/ReferrerInfo.cpp +++ b/dom/security/ReferrerInfo.cpp @@ -32,7 +32,7 @@ #include "mozilla/StaticPrefs_network.h" #include "mozilla/StorageAccess.h" #include "mozilla/StyleSheet.h" -#include "mozilla/Telemetry.h" +#include "mozilla/glean/DomSecurityMetrics.h" #include "nsIWebProgressListener.h" static mozilla::LazyLogModule gReferrerInfoLog("ReferrerInfo"); @@ -1695,8 +1695,8 @@ void ReferrerInfo::RecordTelemetry(nsIHttpChannel* aChannel) { 1 : 0; - Telemetry::Accumulate(Telemetry::REFERRER_POLICY_COUNT, - static_cast(mPolicy) + telemetryOffset); + glean::security::referrer_policy_count.AccumulateSingleSample( + static_cast(mPolicy) + telemetryOffset); } } // namespace mozilla::dom diff --git a/dom/security/metrics.yaml b/dom/security/metrics.yaml index 5135dfbf71c7..ac5e4e81929e 100644 --- a/dom/security/metrics.yaml +++ b/dom/security/metrics.yaml @@ -398,6 +398,71 @@ security: type: string telemetry_mirror: Security_Javascriptload_Parentprocess + https_only_mode_upgrade_time: + type: labeled_timing_distribution + description: > + Time it takes for a request that has been upgraded with HTTPS-Only Mode to + complete, broken down by top-level (top) / sub-resource (sub) and status + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram HTTPS_ONLY_MODE_UPGRADE_TIME_MS. + time_unit: millisecond + labels: + - top_successful + - sub_successful + - top_f_redirectloop + - sub_f_redirectloop + - top_f_timeout + - sub_f_timeout + - top_f_aborted + - sub_f_aborted + - top_f_cxnrefused + - sub_f_cxnrefused + - top_f_ssl_selfsignd + - sub_f_ssl_selfsignd + - top_f_ssl_badcertdm + - sub_f_ssl_badcertdm + - top_f_ssl_unkwnissr + - sub_f_ssl_unkwnissr + - top_f_ssl_other + - sub_f_ssl_other + - top_f_other + - sub_f_other + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1627206 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1627206 + notification_emails: + - julianwels@mozilla.com + - seceng-telemetry@mozilla.com + expires: never + telemetry_mirror: HTTPS_ONLY_MODE_UPGRADE_TIME_MS + + referrer_policy_count: + type: custom_distribution + description: > + The counter of each referrer policy which has been computed for a + referrer. The buckets (0-8) are for same-site requests and buckets (9-17) + are for cross-site requests. Note that the index matches to the order in + ReferrerPolicy.webidl + + This metric was generated to correspond to the Legacy Telemetry enumerated + histogram REFERRER_POLICY_COUNT. + range_min: 0 + range_max: 18 + bucket_count: 19 + histogram_type: linear + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1720869 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1720869 + notification_emails: + - tihuang@mozilla.com + - ckerschbaumer@mozilla.com + - seceng-telemetry@mozilla.com + expires: never + telemetry_mirror: REFERRER_POLICY_COUNT + mixed_content: page_load: type: custom_distribution diff --git a/dom/security/nsHTTPSOnlyStreamListener.cpp b/dom/security/nsHTTPSOnlyStreamListener.cpp index 0148f1c1c098..d647f5f80317 100644 --- a/dom/security/nsHTTPSOnlyStreamListener.cpp +++ b/dom/security/nsHTTPSOnlyStreamListener.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "NSSErrorsService.h" +#include "mozilla/glean/DomSecurityMetrics.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" #include "mozilla/dom/WindowGlobalParent.h" @@ -84,8 +85,7 @@ nsHTTPSOnlyStreamListener::OnStopRequest(nsIRequest* request, void nsHTTPSOnlyStreamListener::RecordUpgradeTelemetry(nsIRequest* request, nsresult aStatus) { // 1. Get time between now and when the initial upgrade request started - int64_t duration = - (mozilla::TimeStamp::Now() - mCreationStart).ToMilliseconds(); + mozilla::TimeDuration duration = mozilla::TimeStamp::Now() - mCreationStart; // 2. Assemble the category string // [!] All strings have to be present in Histograms.json @@ -138,8 +138,8 @@ void nsHTTPSOnlyStreamListener::RecordUpgradeTelemetry(nsIRequest* request, category.AppendLiteral("f_other"); } } - mozilla::Telemetry::Accumulate( - mozilla::Telemetry::HTTPS_ONLY_MODE_UPGRADE_TIME_MS, category, duration); + mozilla::glean::security::https_only_mode_upgrade_time.Get(category) + .AccumulateRawDuration(duration); bool success = NS_SUCCEEDED(aStatus); ExtContentPolicyType externalType = loadInfo->GetExternalContentPolicyType(); @@ -243,6 +243,8 @@ void nsHTTPSOnlyStreamListener::RecordUpgradeTelemetry(nsIRequest* request, } } + // Needs bug 1657470 (New Metric Type: "Keyed Categorical") before + // this can be migrated to Glean. mozilla::Telemetry::Accumulate( mozilla::Telemetry::HTTPS_ONLY_MODE_UPGRADE_TYPE, typeKey, success); }