Bug 1956726 - Migrate histograms to use Glean APIs in extensions/permissions/, r=chutten,permissions-reviewers,emz.

Differential Revision: https://phabricator.services.mozilla.com/D244169
This commit is contained in:
Florian Quèze
2025-04-03 17:30:10 +00:00
parent 80942a3446
commit 1cb736cf28
3 changed files with 48 additions and 3 deletions

View File

@@ -25,7 +25,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/StaticPrefs_permissions.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/ExtensionsPermissionsMetrics.h"
#include "mozIStorageService.h"
#include "mozIStorageConnection.h"
@@ -932,7 +932,7 @@ nsresult PermissionManager::TryInitDB(bool aRemoveFile,
LogToConsole(u"permissions.sqlite is corrupted! Try again!"_ns);
// Add telemetry probe
Telemetry::Accumulate(Telemetry::PERMISSIONS_SQL_CORRUPTED, 1);
glean::permissions::sql_corrupted.Add(1);
// delete corrupted permissions.sqlite and try again
rv = mPermissionsFile->Remove(false);
@@ -960,7 +960,7 @@ nsresult PermissionManager::TryInitDB(bool aRemoveFile,
LogToConsole(u"Defective permissions.sqlite has been removed."_ns);
// Add telemetry probe
Telemetry::Accumulate(Telemetry::DEFECTIVE_PERMISSIONS_SQL_REMOVED, 1);
glean::permissions::defective_sql_removed.Add(1);
rv = OpenDatabase(mPermissionsFile);
NS_ENSURE_SUCCESS(rv, rv);

View File

@@ -0,0 +1,44 @@
# 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 :: Permission Manager'
permissions:
sql_corrupted:
type: counter
description: >
Record the permissions.sqlite init failure
This metric was generated to correspond to the Legacy Telemetry count
histogram PERMISSIONS_SQL_CORRUPTED.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1956726
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1956726
notification_emails:
- amarchesini@mozilla.com
expires: never
telemetry_mirror: h#PERMISSIONS_SQL_CORRUPTED
defective_sql_removed:
type: counter
description: >
Record the removal of defective permissions.sqlite
This metric was generated to correspond to the Legacy Telemetry count
histogram DEFECTIVE_PERMISSIONS_SQL_REMOVED.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1956726
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1956726
notification_emails:
- amarchesini@mozilla.com
expires: never
telemetry_mirror: h#DEFECTIVE_PERMISSIONS_SQL_REMOVED

View File

@@ -46,6 +46,7 @@ gecko_metrics = [
"dom/webauthn/metrics.yaml",
"dom/workers/metrics.yaml",
"editor/libeditor/metrics.yaml",
"extensions/permissions/metrics.yaml",
"gfx/metrics.yaml",
"image/decoders/metrics.yaml",
"ipc/metrics.yaml",