Skip to content

Commit

Permalink
Bug 1918702 - Migrate telemetry events to use Glean APIs in services/…
Browse files Browse the repository at this point in the history
…common/uptake-telemetry.sys.mjs, r=chutten.

Differential Revision: https://phabricator.services.mozilla.com/D222806
  • Loading branch information
fqueze committed Sep 20, 2024
1 parent 432de23 commit e2198f4
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 17 deletions.
93 changes: 93 additions & 0 deletions services/common/metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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:
- 'Cloud Services :: Firefox: Common'

uptake.remotecontent.result:
uptake_remotesettings:
type: event
description: >
Was the remote content successfully pulled? This uptake telemetry
allows to monitor the behaviour of our clients when it comes to
fetching data from remote servers. This helps defect-detection and
allow observation of the proportion of success among clients and
sources, the distribution of error causes, and its evolution over
time.
This event was generated to correspond to the Legacy Telemetry event
uptake.remotecontent.result.uptake#remotesettings.
bugs: &uptake_remotecontent_result_uptake_bugs
- https://bugzil.la/1517469
- https://bugzil.la/1617133
data_reviews: &uptake_remotecontent_result_uptake_data_reviews
- https://bugzil.la/1517469
- https://bugzil.la/1617133
notification_emails: &uptake_remotecontent_result_uptake_emails
- [email protected]
- [email protected]
expires: never
extra_keys: &uptake_remotecontent_result_uptake_extra
value:
description: >
The `value` of the event. Mirrors to the Legacy Telemetry
event's `value` parameter.
type: string
source:
description: >
A label to distinguish what is being pulled or updated in the component (eg. recipe id, settings collection name, ...).
type: string
trigger:
description: >
A label to distinguish what triggered the polling/fetching of remote content (eg. "broadcast", "timer", "forced", "manual")
type: string
age:
description: >
The age of pulled data in seconds (ie. difference between publication time and fetch time).
type: string
duration:
description: >
The duration of the synchronization process in milliseconds.
type: string
timestamp:
description: >
The current timestamp, received during synchronization.
type: string
errorName:
description: >
An optional string with the error name attribute in case of failure.
type: string
telemetry_mirror: UptakeRemotecontentResult_Uptake_Remotesettings
no_lint:
- COMMON_PREFIX

uptake_normandy:
type: event
description: >
Was the remote content successfully pulled? This uptake telemetry
allows to monitor the behaviour of our clients when it comes to
fetching data from remote servers. This helps defect-detection and
allow observation of the proportion of success among clients and
sources, the distribution of error causes, and its evolution over
time.
This event was generated to correspond to the Legacy Telemetry event
uptake.remotecontent.result.uptake#normandy.
bugs: *uptake_remotecontent_result_uptake_bugs
data_reviews: *uptake_remotecontent_result_uptake_data_reviews
notification_emails: *uptake_remotecontent_result_uptake_emails
expires: never
extra_keys: *uptake_remotecontent_result_uptake_extra
telemetry_mirror: UptakeRemotecontentResult_Uptake_Normandy
no_lint:
- COMMON_PREFIX
16 changes: 3 additions & 13 deletions services/common/uptake-telemetry.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class UptakeTelemetry {
/**
* Reports the uptake status for the specified source.
*
* @param {string} component the component reporting the uptake (eg. "normandy").
* @param {string} component the component reporting the uptake (eg. "Normandy").
* @param {string} status the uptake status (eg. "network_error")
* @param {Object} extra extra values to report
* @param {string} extra.source the update source (eg. "recipe-42").
Expand Down Expand Up @@ -176,18 +176,8 @@ export class UptakeTelemetry {
const shouldSendEvent =
!["release", "esr"].includes(channel) || hash < lazy.gSampleRate;
if (shouldSendEvent) {
// The Event API requires `extra` values to be of type string. Force it!
const extraStr = Object.keys(extra).reduce((acc, k) => {
acc[k] = extra[k].toString();
return acc;
}, {});
Services.telemetry.recordEvent(
TELEMETRY_EVENTS_ID,
"uptake",
component,
status,
extraStr
);
extra.value = status;
Glean.uptakeRemotecontentResult["uptake" + component].record(extra);
}
}
}
2 changes: 1 addition & 1 deletion services/settings/RemoteSettingsClient.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
Utils: "resource://services-settings/Utils.sys.mjs",
});

const TELEMETRY_COMPONENT = "remotesettings";
const TELEMETRY_COMPONENT = "Remotesettings";

ChromeUtils.defineLazyGetter(lazy, "console", () => lazy.Utils.log);

Expand Down
2 changes: 1 addition & 1 deletion services/settings/remote-settings.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const PREF_SETTINGS_SYNC_HISTORY_ERROR_THRESHOLD =
"sync_history_error_threshold";

// Telemetry identifiers.
const TELEMETRY_COMPONENT = "remotesettings";
const TELEMETRY_COMPONENT = "Remotesettings";
const TELEMETRY_SOURCE_POLL = "settings-changes-monitoring";
const TELEMETRY_SOURCE_SYNC = "settings-sync";

Expand Down
1 change: 1 addition & 0 deletions toolkit/components/glean/metrics_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"parser/html/metrics.yaml",
"security/certverifier/metrics.yaml",
"security/manager/ssl/metrics.yaml",
"services/common/metrics.yaml",
"toolkit/components/antitracking/bouncetrackingprotection/metrics.yaml",
"toolkit/components/cookiebanners/metrics.yaml",
"toolkit/components/downloads/metrics.yaml",
Expand Down
4 changes: 2 additions & 2 deletions toolkit/components/normandy/lib/Uptake.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { UptakeTelemetry } from "resource://services-common/uptake-telemetry.sys.mjs";

const COMPONENT = "normandy";
const COMPONENT = "Normandy";

export var Uptake = {
// Action uptake
Expand Down Expand Up @@ -43,7 +43,7 @@ export var Uptake = {
);
}
await UptakeTelemetry.report(COMPONENT, status, {
source: `${COMPONENT}/${source}`,
source: `${COMPONENT.toLowerCase()}/${source}`,
});
},

Expand Down

0 comments on commit e2198f4

Please sign in to comment.