Bug 1918702 - Migrate telemetry events to use Glean APIs in browser/components/sessionstore, r=chutten,sessionstore-reviewers,dao.
Differential Revision: https://phabricator.services.mozilla.com/D222127
This commit is contained in:
@@ -253,18 +253,12 @@ var SessionFileInternal = {
|
||||
path,
|
||||
". Wrong format/version: " + JSON.stringify(parsed.version) + "."
|
||||
);
|
||||
Services.telemetry.recordEvent(
|
||||
"session_restore",
|
||||
"backup_can_be_loaded",
|
||||
"session_file",
|
||||
null,
|
||||
{
|
||||
Glean.sessionRestore.backupCanBeLoadedSessionFile.record({
|
||||
can_load: "false",
|
||||
path_key: key,
|
||||
loadfail_reason:
|
||||
"Wrong format/version: " + JSON.stringify(parsed.version) + ".",
|
||||
}
|
||||
);
|
||||
});
|
||||
continue;
|
||||
}
|
||||
result = {
|
||||
@@ -273,17 +267,11 @@ var SessionFileInternal = {
|
||||
parsed,
|
||||
useOldExtension,
|
||||
};
|
||||
Services.telemetry.recordEvent(
|
||||
"session_restore",
|
||||
"backup_can_be_loaded",
|
||||
"session_file",
|
||||
null,
|
||||
{
|
||||
Glean.sessionRestore.backupCanBeLoadedSessionFile.record({
|
||||
can_load: "true",
|
||||
path_key: key,
|
||||
loadfail_reason: "N/A",
|
||||
}
|
||||
);
|
||||
});
|
||||
Services.telemetry
|
||||
.getHistogramById("FX_SESSION_RESTORE_CORRUPT_FILE")
|
||||
.add(false);
|
||||
@@ -295,17 +283,11 @@ var SessionFileInternal = {
|
||||
} catch (ex) {
|
||||
if (DOMException.isInstance(ex) && ex.name == "NotFoundError") {
|
||||
exists = false;
|
||||
Services.telemetry.recordEvent(
|
||||
"session_restore",
|
||||
"backup_can_be_loaded",
|
||||
"session_file",
|
||||
null,
|
||||
{
|
||||
Glean.sessionRestore.backupCanBeLoadedSessionFile.record({
|
||||
can_load: "false",
|
||||
path_key: key,
|
||||
loadfail_reason: "File doesn't exist.",
|
||||
}
|
||||
);
|
||||
});
|
||||
// A file not existing can be normal and expected.
|
||||
lazy.sessionStoreLogger.debug(
|
||||
`Can't read session file which doesn't exist: ${key}`
|
||||
@@ -321,17 +303,11 @@ var SessionFileInternal = {
|
||||
ex
|
||||
);
|
||||
corrupted = true;
|
||||
Services.telemetry.recordEvent(
|
||||
"session_restore",
|
||||
"backup_can_be_loaded",
|
||||
"session_file",
|
||||
null,
|
||||
{
|
||||
Glean.sessionRestore.backupCanBeLoadedSessionFile.record({
|
||||
can_load: "false",
|
||||
path_key: key,
|
||||
loadfail_reason: ` ${ex.name}: Could not read session file`,
|
||||
}
|
||||
);
|
||||
});
|
||||
} else if (ex instanceof SyntaxError) {
|
||||
lazy.sessionStoreLogger.error(
|
||||
"Corrupt session file (invalid JSON found) ",
|
||||
@@ -340,17 +316,11 @@ var SessionFileInternal = {
|
||||
);
|
||||
// File is corrupted, try next file
|
||||
corrupted = true;
|
||||
Services.telemetry.recordEvent(
|
||||
"session_restore",
|
||||
"backup_can_be_loaded",
|
||||
"session_file",
|
||||
null,
|
||||
{
|
||||
Glean.sessionRestore.backupCanBeLoadedSessionFile.record({
|
||||
can_load: "false",
|
||||
path_key: key,
|
||||
loadfail_reason: ` ${ex.name}: Corrupt session file (invalid JSON found)`,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
if (exists) {
|
||||
@@ -358,17 +328,11 @@ var SessionFileInternal = {
|
||||
Services.telemetry
|
||||
.getHistogramById("FX_SESSION_RESTORE_CORRUPT_FILE")
|
||||
.add(corrupted);
|
||||
Services.telemetry.recordEvent(
|
||||
"session_restore",
|
||||
"backup_can_be_loaded",
|
||||
"session_file",
|
||||
null,
|
||||
{
|
||||
Glean.sessionRestore.backupCanBeLoadedSessionFile.record({
|
||||
can_load: (!corrupted).toString(),
|
||||
path_key: key,
|
||||
loadfail_reason: "N/A",
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,16 +269,10 @@ export var SessionStartup = {
|
||||
Services.telemetry
|
||||
.getHistogramById("SHUTDOWN_OK")
|
||||
.add(!this._previousSessionCrashed);
|
||||
Services.telemetry.recordEvent(
|
||||
"session_restore",
|
||||
"shutdown_success",
|
||||
"session_startup",
|
||||
null,
|
||||
{
|
||||
Glean.sessionRestore.shutdownSuccessSessionStartup.record({
|
||||
shutdown_ok: this._previousSessionCrashed.toString(),
|
||||
shutdown_reason: previousSessionCrashedReason,
|
||||
}
|
||||
);
|
||||
});
|
||||
lazy.sessionStoreLogger.debug(
|
||||
`Previous shutdown ok? ${this._previousSessionCrashed}, reason: ${previousSessionCrashedReason}`
|
||||
);
|
||||
|
||||
64
browser/components/sessionstore/metrics.yaml
Normal file
64
browser/components/sessionstore/metrics.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
# 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:
|
||||
- 'Firefox :: Session Restore'
|
||||
|
||||
session_restore:
|
||||
backup_can_be_loaded_session_file:
|
||||
type: event
|
||||
description: >
|
||||
Recorded when a file is able to be successfully read on startup
|
||||
This event was generated to correspond to the Legacy Telemetry event
|
||||
session_restore.backup_can_be_loaded#session_file.
|
||||
bugs:
|
||||
- https://bugzil.la/1874742
|
||||
data_reviews:
|
||||
- https://bugzil.la/1874742
|
||||
notification_emails:
|
||||
- session-restore-telemetry-alerts@mozilla.com
|
||||
expires: never
|
||||
extra_keys:
|
||||
can_load:
|
||||
description: >
|
||||
Whether or not the startup file can be read/loaded
|
||||
type: string
|
||||
path_key:
|
||||
description: >
|
||||
A symbolic name for the backup file, should be one of "clean", "recovery", "recoveryBackup", "cleanBackup", or "upgradeBackup"
|
||||
type: string
|
||||
loadfail_reason:
|
||||
description: >
|
||||
Reason why the file cannot be loaded, N/A if can be loaded
|
||||
type: string
|
||||
telemetry_mirror: Session_restore_BackupCanBeLoaded_SessionFile
|
||||
|
||||
shutdown_success_session_startup:
|
||||
type: event
|
||||
description: >
|
||||
Report shutdown success
|
||||
This event was generated to correspond to the Legacy Telemetry event
|
||||
session_restore.shutdown_success#session_startup.
|
||||
bugs:
|
||||
- https://bugzil.la/1874742
|
||||
data_reviews:
|
||||
- https://bugzil.la/1874742
|
||||
notification_emails:
|
||||
- session-restore-telemetry-alerts@mozilla.com
|
||||
expires: never
|
||||
extra_keys:
|
||||
shutdown_ok:
|
||||
description: >
|
||||
Whether or not the shutdown happened successfully, unsuccessful if previous session crashed
|
||||
type: string
|
||||
shutdown_reason:
|
||||
description: >
|
||||
Reason why shutdown didn't happen successfully, N/A if previous session didn't crashed
|
||||
type: string
|
||||
telemetry_mirror: Session_restore_ShutdownSuccess_SessionStartup
|
||||
@@ -69,6 +69,7 @@ firefox_desktop_metrics = [
|
||||
"browser/components/privatebrowsing/metrics.yaml",
|
||||
"browser/components/protocolhandler/metrics.yaml",
|
||||
"browser/components/search/metrics.yaml",
|
||||
"browser/components/sessionstore/metrics.yaml",
|
||||
"browser/components/shopping/metrics.yaml",
|
||||
"browser/components/sidebar/metrics.yaml",
|
||||
"browser/components/urlbar/metrics.yaml",
|
||||
|
||||
Reference in New Issue
Block a user