From cc6e2ffdbf3988f5af374685f4d84ad471c67009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Tue, 8 Apr 2025 08:42:01 +0000 Subject: [PATCH] Bug 1956726 - Migrate histograms to use Glean APIs for REL_PRELOAD_MISS_RATIO, r=chutten,necko-reviewers,sunil. Differential Revision: https://phabricator.services.mozilla.com/D244294 --- netwerk/metrics.yaml | 39 +++++++++++++++++++++++++++++ uriloader/preload/PreloaderBase.cpp | 6 ++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/netwerk/metrics.yaml b/netwerk/metrics.yaml index 224b088806ee..92c89900026e 100644 --- a/netwerk/metrics.yaml +++ b/netwerk/metrics.yaml @@ -3168,3 +3168,42 @@ network: - necko@mozilla.com expires: never telemetry_mirror: IPV4_AND_IPV6_ADDRESS_CONNECTIVITY + + rel_preload_miss_ratio: + type: labeled_counter + description: > + Ratio of used and unused resources preloaded with link rel=preload tag or + response header, broken down by supported resource type. + + This metric was generated to correspond to the Legacy Telemetry + categorical histogram REL_PRELOAD_MISS_RATIO. + labels: + - TYPE_SCRIPT_USED + - TYPE_SCRIPT_UNUSED + - TYPE_STYLE_USED + - TYPE_STYLE_UNUSED + - TYPE_IMAGE_USED + - TYPE_IMAGE_UNUSED + - TYPE_FONT_USED + - TYPE_FONT_UNUSED + - TYPE_FETCH_USED + - TYPE_FETCH_UNUSED + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1658532 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1583604 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666981 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1700831 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1736687 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777403 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1658532 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1583604 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666981 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1700831 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1736687 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777403 + notification_emails: + - necko@mozilla.com + - kershaw@mozilla.com + expires: never + telemetry_mirror: h#REL_PRELOAD_MISS_RATIO diff --git a/uriloader/preload/PreloaderBase.cpp b/uriloader/preload/PreloaderBase.cpp index 9ae2f85a0f6b..5e4b386e51fc 100644 --- a/uriloader/preload/PreloaderBase.cpp +++ b/uriloader/preload/PreloaderBase.cpp @@ -5,7 +5,7 @@ #include "PreloaderBase.h" #include "mozilla/dom/Document.h" -#include "mozilla/Telemetry.h" +#include "mozilla/glean/NetwerkMetrics.h" #include "nsContentUtils.h" #include "nsIAsyncVerifyRedirectCallback.h" #include "nsIHttpChannel.h" @@ -322,8 +322,8 @@ void PreloaderBase::ReportUsageTelemetry() { ++index; } - auto label = static_cast(index); - Telemetry::AccumulateCategorical(label); + auto label = static_cast(index); + glean::network::rel_preload_miss_ratio.EnumGet(label).Add(); } nsresult PreloaderBase::AsyncConsume(nsIStreamListener* aListener) {