diff --git a/toolkit/components/extensions/ExtensionTelemetry.sys.mjs b/toolkit/components/extensions/ExtensionTelemetry.sys.mjs index 58368c01f2d9..8f635fadebc0 100644 --- a/toolkit/components/extensions/ExtensionTelemetry.sys.mjs +++ b/toolkit/components/extensions/ExtensionTelemetry.sys.mjs @@ -10,16 +10,9 @@ const { DefaultWeakMap } = ExtensionUtils; // Map of the base histogram ids for the metrics recorded for the extensions. const HISTOGRAMS_IDS = { - backgroundPageLoad: "WEBEXT_BACKGROUND_PAGE_LOAD_MS", - browserActionPopupOpen: "WEBEXT_BROWSERACTION_POPUP_OPEN_MS", browserActionPreloadResult: "WEBEXT_BROWSERACTION_POPUP_PRELOAD_RESULT_COUNT", - contentScriptInjection: "WEBEXT_CONTENT_SCRIPT_INJECTION_MS", eventPageRunningTime: "WEBEXT_EVENTPAGE_RUNNING_TIME_MS", eventPageIdleResult: "WEBEXT_EVENTPAGE_IDLE_RESULT_COUNT", - extensionStartup: "WEBEXT_EXTENSION_STARTUP_MS", - pageActionPopupOpen: "WEBEXT_PAGEACTION_POPUP_OPEN_MS", - storageLocalGetIdb: "WEBEXT_STORAGE_LOCAL_IDB_GET_MS", - storageLocalSetIdb: "WEBEXT_STORAGE_LOCAL_IDB_SET_MS", }; const GLEAN_METRICS_TYPES = { @@ -105,12 +98,10 @@ class ExtensionTelemetryMetric { // Stopwatch methods. stopwatchStart(extension, obj = extension) { - this._wrappedStopwatchMethod("start", this.metric, extension, obj); this._wrappedTimingDistributionMethod("start", this.metric, extension, obj); } stopwatchFinish(extension, obj = extension) { - this._wrappedStopwatchMethod("finish", this.metric, extension, obj); this._wrappedTimingDistributionMethod( "stopAndAccumulate", this.metric, @@ -120,7 +111,6 @@ class ExtensionTelemetryMetric { } stopwatchCancel(extension, obj = extension) { - this._wrappedStopwatchMethod("cancel", this.metric, extension, obj); this._wrappedTimingDistributionMethod( "cancel", this.metric, @@ -167,10 +157,18 @@ class ExtensionTelemetryMetric { return; } + let extensionId = getTrimmedString(extension.id); + // Capitalization on 'ByAddonid' is a result of glean naming rules. + let metricByAddonid = metric + "ByAddonid"; + switch (method) { case "start": { const timerId = Glean.extensionsTiming[metric].start(); - this.gleanTimerIdsMap.get(extension).set(obj, timerId); + const labeledTimerId = + Glean.extensionsTiming[metricByAddonid][extensionId].start(); + this.gleanTimerIdsMap + .get(extension) + .set(obj, { timerId, labeledTimerId }); break; } case "stopAndAccumulate": // Intentional fall-through. @@ -184,9 +182,14 @@ class ExtensionTelemetryMetric { ); return; } - const timerId = this.gleanTimerIdsMap.get(extension).get(obj); + const { timerId, labeledTimerId } = this.gleanTimerIdsMap + .get(extension) + .get(obj); this.gleanTimerIdsMap.get(extension).delete(obj); Glean.extensionsTiming[metric][method](timerId); + Glean.extensionsTiming[metricByAddonid][extensionId][method]( + labeledTimerId + ); break; } default: @@ -196,42 +199,6 @@ class ExtensionTelemetryMetric { } } - /** - * Wraps a call to a TelemetryStopwatch method for a given metric and extension. - * - * @param {string} method - * The stopwatch method to call ("start", "finish" or "cancel"). - * @param {string} metric - * The stopwatch metric to record (used to retrieve the base histogram id from the HISTOGRAMS_IDS object). - * @param {Extension | ExtensionChild} extension - * The extension to record the telemetry for. - * @param {any | undefined} [obj = extension] - * An optional telemetry stopwatch object (which defaults to the extension parameter when missing). - */ - _wrappedStopwatchMethod(method, metric, extension, obj = extension) { - if (!extension) { - Cu.reportError(`Mandatory extension parameter is undefined`); - return; - } - - const baseId = HISTOGRAMS_IDS[metric]; - if (!baseId) { - Cu.reportError(`Unknown metric ${metric}`); - return; - } - - // Record metric in the general histogram. - TelemetryStopwatch[method](baseId, obj); - - // Record metric in the histogram keyed by addon id. - let extensionId = getTrimmedString(extension.id); - TelemetryStopwatch[`${method}Keyed`]( - `${baseId}_BY_ADDONID`, - extensionId, - obj - ); - } - /** * Record a telemetry category and/or value for a given metric. * @@ -257,24 +224,8 @@ class ExtensionTelemetryMetric { return; } - const histogram = Services.telemetry.getHistogramById(baseId); - if (typeof category === "string") { - histogram.add(category, value); - } else { - histogram.add(value); - } - - const keyedHistogram = Services.telemetry.getKeyedHistogramById( - `${baseId}_BY_ADDONID` - ); const extensionId = getTrimmedString(extension.id); - if (typeof category === "string") { - keyedHistogram.add(extensionId, category, value); - } else { - keyedHistogram.add(extensionId, value); - } - switch (GLEAN_METRICS_TYPES[metric]) { case "custom_distribution": { if (typeof category === "string") { @@ -287,6 +238,10 @@ class ExtensionTelemetryMetric { // map once we may introduce new histograms that are not part of the // extensionsTiming Glean metrics category. Glean.extensionsTiming[metric].accumulateSingleSample(value); + // Capitalization on 'ByAddonid' is a result of glean naming rules. + Glean.extensionsTiming[metric + "ByAddonid"][ + extensionId + ].accumulateSingleSample(value); break; } case "labeled_counter": { @@ -297,6 +252,12 @@ class ExtensionTelemetryMetric { return; } Glean.extensionsCounters[metric][category].add(value ?? 1); + + // TODO: migrate this to Glean once bug 1657470 is fixed. + Services.telemetry + .getKeyedHistogramById(`${baseId}_BY_ADDONID`) + .add(extensionId, category, value); + break; } default: @@ -314,7 +275,7 @@ const metricsCache = new Map(); /** * This proxy object provides the telemetry helpers for the currently supported metrics (the ones listed in - * HISTOGRAMS_IDS), the telemetry helpers for a particular metric are lazily created + * GLEAN_METRICS_TYPES), the telemetry helpers for a particular metric are lazily created * when the related property is being accessed on this object for the first time, e.g.: * * ExtensionTelemetry.extensionStartup.stopwatchStart(extension); @@ -324,10 +285,7 @@ const metricsCache = new Map(); // @ts-ignore no easy way in TS to say Proxy is a different type from target. export var ExtensionTelemetry = new Proxy(metricsCache, { get(target, prop) { - // NOTE: if we would be start adding glean probes that do not have a unified - // telemetry histogram counterpart, we would need to change this check - // accordingly. - if (!(prop in HISTOGRAMS_IDS)) { + if (!(prop in GLEAN_METRICS_TYPES)) { throw new Error(`Unknown metric ${String(prop)}`); } diff --git a/toolkit/components/extensions/metrics.yaml b/toolkit/components/extensions/metrics.yaml index fac9ffebe8a3..13c8f59318e6 100644 --- a/toolkit/components/extensions/metrics.yaml +++ b/toolkit/components/extensions/metrics.yaml @@ -437,6 +437,9 @@ extensions.counters: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: h#WEBEXT_BROWSERACTION_POPUP_PRELOAD_RESULT_COUNT + no_lint: + - GIFFT_NON_PING_LIFETIME event_page_idle_result: type: labeled_counter @@ -467,6 +470,9 @@ extensions.counters: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: h#WEBEXT_EVENTPAGE_IDLE_RESULT_COUNT + no_lint: + - GIFFT_NON_PING_LIFETIME extensions.timing: @@ -487,6 +493,47 @@ extensions.timing: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: WEBEXT_BACKGROUND_PAGE_LOAD_MS + + background_page_load_by_addonid: + type: labeled_timing_distribution + description: > + The amount of time it takes to load a WebExtensions background page, from + when the build function is called to when the page has finished processing + the onload event, keyed by addon id. + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram WEBEXT_BACKGROUND_PAGE_LOAD_MS_BY_ADDONID. + time_unit: millisecond + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + notification_emails: + - addons-dev-internal@mozilla.com + - lgreco@mozilla.com + expires: 140 + telemetry_mirror: WEBEXT_BACKGROUND_PAGE_LOAD_MS_BY_ADDONID browser_action_popup_open: type: timing_distribution @@ -512,6 +559,46 @@ extensions.timing: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: WEBEXT_BROWSERACTION_POPUP_OPEN_MS + + browser_action_popup_open_by_addonid: + type: labeled_timing_distribution + description: > + The amount of time it takes for a BrowserAction popup to open, keyed by + addon id. + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram WEBEXT_BROWSERACTION_POPUP_OPEN_MS_BY_ADDONID. + time_unit: millisecond + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + notification_emails: + - addons-dev-internal@mozilla.com + - lgreco@mozilla.com + expires: 140 + telemetry_mirror: WEBEXT_BROWSERACTION_POPUP_OPEN_MS_BY_ADDONID content_script_injection: type: timing_distribution @@ -529,6 +616,46 @@ extensions.timing: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: WEBEXT_CONTENT_SCRIPT_INJECTION_MS + + content_script_injection_by_addonid: + type: labeled_timing_distribution + description: > + The amount of time it takes for content scripts from a WebExtension to be + injected into a window, keyed by addon id. + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram WEBEXT_CONTENT_SCRIPT_INJECTION_MS_BY_ADDONID. + time_unit: millisecond + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + notification_emails: + - addons-dev-internal@mozilla.com + - lgreco@mozilla.com + expires: 140 + telemetry_mirror: WEBEXT_CONTENT_SCRIPT_INJECTION_MS_BY_ADDONID event_page_running_time: type: custom_distribution @@ -550,6 +677,32 @@ extensions.timing: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: WEBEXT_EVENTPAGE_RUNNING_TIME_MS + + event_page_running_time_by_addonid: + type: labeled_timing_distribution + description: > + The amount of time (keyed by addon id) that an event page has been running + before being suspended, or the entire addon shutdown. + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram WEBEXT_EVENTPAGE_RUNNING_TIME_MS_BY_ADDONID. + time_unit: millisecond + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1787940 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1817103 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1787940 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1817103 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + notification_emails: + - addons-dev-internal@mozilla.com + - lgreco@mozilla.com + expires: 140 + telemetry_mirror: WEBEXT_EVENTPAGE_RUNNING_TIME_MS_BY_ADDONID extension_startup: type: timing_distribution @@ -568,6 +721,47 @@ extensions.timing: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: WEBEXT_EXTENSION_STARTUP_MS + + extension_startup_by_addonid: + type: labeled_timing_distribution + description: > + The amount of time it takes for a WebExtension to start up, from when the + startup function is called to when the startup promise resolves, keyed by + addon id. + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram WEBEXT_EXTENSION_STARTUP_MS_BY_ADDONID. + time_unit: millisecond + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + notification_emails: + - addons-dev-internal@mozilla.com + - lgreco@mozilla.com + expires: 140 + telemetry_mirror: WEBEXT_EXTENSION_STARTUP_MS_BY_ADDONID page_action_popup_open: type: timing_distribution @@ -593,6 +787,46 @@ extensions.timing: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: WEBEXT_PAGEACTION_POPUP_OPEN_MS + + page_action_popup_open_by_addonid: + type: labeled_timing_distribution + description: > + The amount of time it takes for a PageAction popup to open, keyed by addon + id. + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram WEBEXT_PAGEACTION_POPUP_OPEN_MS_BY_ADDONID. + time_unit: millisecond + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + notification_emails: + - addons-dev-internal@mozilla.com + - lgreco@mozilla.com + expires: 140 + telemetry_mirror: WEBEXT_PAGEACTION_POPUP_OPEN_MS_BY_ADDONID storage_local_get_idb: type: timing_distribution @@ -618,6 +852,46 @@ extensions.timing: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: WEBEXT_STORAGE_LOCAL_IDB_GET_MS + + storage_local_get_idb_by_addonid: + type: labeled_timing_distribution + description: > + The amount of time it takes to perform a get via storage.local using the + IndexedDB backend, keyed by addon id. + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram WEBEXT_STORAGE_LOCAL_IDB_GET_MS_BY_ADDONID. + time_unit: millisecond + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + notification_emails: + - addons-dev-internal@mozilla.com + - lgreco@mozilla.com + expires: 140 + telemetry_mirror: WEBEXT_STORAGE_LOCAL_IDB_GET_MS_BY_ADDONID storage_local_set_idb: type: timing_distribution @@ -643,3 +917,43 @@ extensions.timing: - https://bugzilla.mozilla.org/show_bug.cgi?id=1820158#c8 data_sensitivity: - technical + telemetry_mirror: WEBEXT_STORAGE_LOCAL_IDB_SET_MS + + storage_local_set_idb_by_addonid: + type: labeled_timing_distribution + description: > + The amount of time it takes to perform a set via storage.local using the + IndexedDB backend, keyed by addon id. + + This metric was generated to correspond to the Legacy Telemetry + exponential histogram WEBEXT_STORAGE_LOCAL_IDB_SET_MS_BY_ADDONID. + time_unit: millisecond + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1483002 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1513556 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1578225 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1623315 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1666980 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1706839 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1745271 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1777402 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1811155 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1861303 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1912170 + notification_emails: + - addons-dev-internal@mozilla.com + - lgreco@mozilla.com + expires: 140 + telemetry_mirror: WEBEXT_STORAGE_LOCAL_IDB_SET_MS_BY_ADDONID diff --git a/toolkit/components/extensions/parent/ext-backgroundPage.js b/toolkit/components/extensions/parent/ext-backgroundPage.js index 67ed9a77c25a..d54d36d6f713 100644 --- a/toolkit/components/extensions/parent/ext-backgroundPage.js +++ b/toolkit/components/extensions/parent/ext-backgroundPage.js @@ -1065,11 +1065,16 @@ var IdleManager = class IdleManager { } if (Cu.now() - start > backgroundIdleTimeout) { - ExtensionTelemetry.eventPageIdleResult.histogramAdd({ - extension: this.extension, - category: reason, - value: Math.round((Cu.now() - start) / backgroundIdleTimeout), - }); + let value = Math.round((Cu.now() - start) / backgroundIdleTimeout); + // GIFFT doesn't support mirroring to a categorical histogram with + // values that are not 1, so do the histogramAdd call as many times + // as needed. It will be once most of the time, sometimes twice. + while (value--) { + ExtensionTelemetry.eventPageIdleResult.histogramAdd({ + extension: this.extension, + category: reason, + }); + } } }); } diff --git a/tools/@types/glean/toolkit_components_extensions.d.ts b/tools/@types/glean/toolkit_components_extensions.d.ts index 69923705943e..2f6f643070bf 100644 --- a/tools/@types/glean/toolkit_components_extensions.d.ts +++ b/tools/@types/glean/toolkit_components_extensions.d.ts @@ -30,6 +30,7 @@ interface GleanImpl { migrateResult: GleanEvent; storageLocalError: GleanEvent; syncUsageQuotas: GleanEvent; + migrateResultCount: Record; } extensionsCounters: { @@ -39,12 +40,20 @@ interface GleanImpl { extensionsTiming: { backgroundPageLoad: GleanTimingDistribution; + backgroundPageLoadByAddonid: Record; browserActionPopupOpen: GleanTimingDistribution; + browserActionPopupOpenByAddonid: Record; contentScriptInjection: GleanTimingDistribution; + contentScriptInjectionByAddonid: Record; eventPageRunningTime: GleanCustomDistribution; + eventPageRunningTimeByAddonid: Record; extensionStartup: GleanTimingDistribution; + extensionStartupByAddonid: Record; pageActionPopupOpen: GleanTimingDistribution; + pageActionPopupOpenByAddonid: Record; storageLocalGetIdb: GleanTimingDistribution; + storageLocalGetIdbByAddonid: Record; storageLocalSetIdb: GleanTimingDistribution; + storageLocalSetIdbByAddonid: Record; } }