Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 58a5bb3

Browse files
committed
Bug 1944631 - Migrate histograms to use Glean APIs in dom/storage, r=chutten.
Differential Revision: https://phabricator.services.mozilla.com/D235631
1 parent 179b869 commit 58a5bb3

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed

dom/storage/LocalStorageCache.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "nsDOMString.h"
1616
#include "nsXULAppAPI.h"
1717
#include "mozilla/Unused.h"
18+
#include "mozilla/glean/DomStorageMetrics.h"
1819
#include "nsProxyRelease.h"
1920
#include "nsThreadUtils.h"
2021

@@ -237,8 +238,11 @@ void LocalStorageCache::WaitForPreload() {
237238
// Telemetry of rates of pending preloads
238239
if (!mPreloadTelemetryRecorded) {
239240
mPreloadTelemetryRecorded = true;
240-
Telemetry::Accumulate(
241-
Telemetry::LOCALDOMSTORAGE_PRELOAD_PENDING_ON_FIRST_ACCESS, !loaded);
241+
glean::localdomstorage::preload_pending_on_first_access
242+
.EnumGet(static_cast<
243+
glean::localdomstorage::PreloadPendingOnFirstAccessLabel>(
244+
!loaded))
245+
.Add();
242246
}
243247

244248
if (loaded) {

dom/storage/LocalStorageCache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "nsTHashMap.h"
1414
#include "nsHashKeys.h"
1515
#include "mozilla/Monitor.h"
16-
#include "mozilla/Telemetry.h"
1716
#include "mozilla/Atomics.h"
1817

1918
namespace mozilla::dom {

dom/storage/StorageDBThread.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "mozIStorageValueArray.h"
2525
#include "mozIStorageFunction.h"
2626
#include "mozilla/BasePrincipal.h"
27+
#include "mozilla/glean/DomStorageMetrics.h"
2728
#include "mozilla/ipc/BackgroundParent.h"
2829
#include "nsIObserverService.h"
2930
#include "nsThread.h"
@@ -248,7 +249,7 @@ nsresult StorageDBThread::Shutdown() {
248249
return NS_ERROR_NOT_INITIALIZED;
249250
}
250251

251-
Telemetry::AutoTimer<Telemetry::LOCALDOMSTORAGE_SHUTDOWN_DATABASE_MS> timer;
252+
auto timer = glean::localdomstorage::shutdown_database.Measure();
252253

253254
{
254255
MonitorAutoLock monitor(mThreadObserver->GetMonitor());

dom/storage/metrics.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
# Adding a new metric? We have docs for that!
6+
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
7+
8+
---
9+
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
10+
$tags:
11+
- 'Core :: Storage: localStorage & sessionStorage'
12+
13+
localdomstorage:
14+
shutdown_database:
15+
type: timing_distribution
16+
description: >
17+
Time to flush and close the localStorage database (ms)
18+
19+
This metric was generated to correspond to the Legacy Telemetry
20+
exponential histogram LOCALDOMSTORAGE_SHUTDOWN_DATABASE_MS.
21+
time_unit: millisecond
22+
bugs:
23+
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
24+
data_reviews:
25+
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
26+
notification_emails:
27+
28+
expires: never
29+
telemetry_mirror: LOCALDOMSTORAGE_SHUTDOWN_DATABASE_MS
30+
31+
preload_pending_on_first_access:
32+
type: labeled_counter
33+
description: >
34+
True when we had to wait for a pending preload on first access to
35+
localStorage data, false otherwise
36+
37+
This metric was generated to correspond to the Legacy Telemetry boolean
38+
histogram LOCALDOMSTORAGE_PRELOAD_PENDING_ON_FIRST_ACCESS.
39+
labels:
40+
- "false"
41+
- "true"
42+
bugs:
43+
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
44+
data_reviews:
45+
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
46+
notification_emails:
47+
48+
expires: never
49+
telemetry_mirror: h#LOCALDOMSTORAGE_PRELOAD_PENDING_ON_FIRST_ACCESS

toolkit/components/glean/metrics_index.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"dom/push/metrics.yaml",
4040
"dom/quota/metrics.yaml",
4141
"dom/security/metrics.yaml",
42+
"dom/storage/metrics.yaml",
4243
"dom/webauthn/metrics.yaml",
4344
"gfx/metrics.yaml",
4445
"image/decoders/metrics.yaml",

0 commit comments

Comments
 (0)