diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index 38fc6152a428..a492e52010a2 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -29,7 +29,7 @@ #include "nsITimer.h" #include "mozilla/Omnijar.h" #include "prenv.h" -#include "mozilla/Telemetry.h" +#include "mozilla/glean/StartupcacheMetrics.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" #include "nsIProtocolHandler.h" @@ -377,10 +377,9 @@ nsresult StartupCache::GetBuffer(const char* id, const char** outbuf, NS_ASSERTION(NS_IsMainThread(), "Startup cache only available on main thread"); - Telemetry::LABELS_STARTUP_CACHE_REQUESTS label = - Telemetry::LABELS_STARTUP_CACHE_REQUESTS::Miss; - auto telemetry = - MakeScopeExit([&label] { Telemetry::AccumulateCategorical(label); }); + auto label = glean::startup_cache::RequestsLabel::eMiss; + auto telemetry = MakeScopeExit( + [&label] { glean::startup_cache::requests.EnumGet(label).Add(); }); MutexAutoLock lock(mTableLock); decltype(mTable)::Ptr p = mTable.lookup(nsDependentCString(id)); @@ -390,7 +389,7 @@ nsresult StartupCache::GetBuffer(const char* id, const char** outbuf, auto& value = p->value(); if (value.mData) { - label = Telemetry::LABELS_STARTUP_CACHE_REQUESTS::HitMemory; + label = glean::startup_cache::RequestsLabel::eHitmemory; } else { if (!mCacheData.initialized()) { return NS_ERROR_NOT_AVAILABLE; @@ -432,7 +431,7 @@ nsresult StartupCache::GetBuffer(const char* id, const char** outbuf, MMAP_FAULT_HANDLER_CATCH(NS_ERROR_FAILURE) - label = Telemetry::LABELS_STARTUP_CACHE_REQUESTS::HitDisk; + label = glean::startup_cache::RequestsLabel::eHitdisk; } if (!value.mRequested) { diff --git a/startupcache/metrics.yaml b/startupcache/metrics.yaml new file mode 100644 index 000000000000..8180627b8fb9 --- /dev/null +++ b/startupcache/metrics.yaml @@ -0,0 +1,43 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Adding a new metric? We have docs for that! +# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html + +--- +$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0 +$tags: + - 'Core :: XPCOM' + +startup_cache: + requests: + type: labeled_counter + description: > + Record hits and misses to the startup cache, with categories. + + This metric was generated to correspond to the Legacy Telemetry + categorical histogram STARTUP_CACHE_REQUESTS. + labels: + - HitMemory + - HitDisk + - Miss + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1364235 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1590385 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623098 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1649954 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1689257 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1754639 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1364235 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1590385 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623098 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1649954 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1689257 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1754639 + notification_emails: + - dothayer@mozilla.com + - plawless@mozilla.com + expires: never + telemetry_mirror: h#STARTUP_CACHE_REQUESTS diff --git a/toolkit/components/glean/metrics_index.py b/toolkit/components/glean/metrics_index.py index d462463a7dc1..8a7e56e7abb8 100644 --- a/toolkit/components/glean/metrics_index.py +++ b/toolkit/components/glean/metrics_index.py @@ -65,6 +65,7 @@ gecko_metrics = [ "security/manager/ssl/metrics.yaml", "services/common/metrics.yaml", "services/sync/modules/metrics.yaml", + "startupcache/metrics.yaml", "toolkit/components/antitracking/bouncetrackingprotection/metrics.yaml", "toolkit/components/antitracking/metrics.yaml", "toolkit/components/captchadetection/metrics.yaml",