From 42245a5b45a895e7ab15585dee9e948fdb539527 Mon Sep 17 00:00:00 2001 From: Perry McManis Date: Fri, 9 Feb 2024 21:11:05 +0000 Subject: [PATCH] Bug 1877576 - Migrate geckoview GVST probes r=geckoview-reviewers,perry.mcmanis,owlish Most are brought over straightforwardly, their Telemetry callsites reworded to use Glean, with mirroring to the Telemetry probes taken care of by the Glean Interface For Firefox Telemetry (see the telemetry_mirror property). There were some special cases: * HistogramStopwatch becomes GleanStopwatch. After migration it was only serving Glean consumers. Could've used standard Glean APIs, but having something to hold the TimerIds was convenient. * GV_STARTUP_MODULES_MS was removed. It was configured to only report for the `firefox` product, but could only have a value in `geckoview_streaming`, so never reported data. * MEDIA_DECODING_PROCESS_CRASH was removed. It was configured to only report for the `firefox` product, but could only have a value in `geckoview_streaming`, so never reported data. * GV_CONTENT_PROCESS_LIFETIME_MS was removed. It was configured to only report for the `geckoview_streaming` product, meaning it only reported data when used with GVST to reach the Glean `geckoview.content_process_lifetime` metric. This is now accomplished directly. * GV_STARTUP_RUNTIME_MS was removed. Though it was configured to report data for both `firefox` and `geckoview_streaming` products, it only ever had values in geckoview. Its data continues to be reported via `geckoview.startup_runtime`. * gecko.version and gecko.build_id (Scalars) were removed. In Firefox Desktop this information is available in the `application` section of the Environment. In geckoview-using products, this information continues to be available via `geckoview.version` and `geckoview.build_id`. * GV_STARTUP_RUNTIME_MS and GV_CONTENT_PROCESS_LIFETIME_MS are handled oddly. Since those probes were recorded in the Java portion of the code, and that portion doesn't include Glean, we use `nativeAddHistogram` to relay the samples for those two pieces of instrumentation. If there will be more instrumentation landing in that part of the code, I recommend you review the instructions for including the Glean SDK in a library, and retire this use of JNI. Differential Revision: https://phabricator.services.mozilla.com/D200094 --- dom/ipc/WindowGlobalParent.cpp | 6 +- mobile/android/chrome/geckoview/geckoview.js | 10 -- .../mozilla/gecko/media/RemoteManager.java | 2 - .../geckoview/GeckoViewProgress.sys.mjs | 34 ++-- .../geckoview/GeckoViewTelemetry.sys.mjs | 23 ++- mobile/android/modules/geckoview/metrics.yaml | 153 ++++++++++++++++ toolkit/components/glean/metrics_index.py | 3 +- toolkit/components/telemetry/Histograms.json | 53 +----- toolkit/components/telemetry/Scalars.yaml | 36 ---- .../geckoview/streaming/metrics.yaml | 168 ------------------ toolkit/modules/BrowserTelemetryUtils.sys.mjs | 5 +- toolkit/xre/metrics.yaml | 39 ++++ toolkit/xre/nsAppRunner.cpp | 7 +- widget/android/Telemetry.h | 12 +- 14 files changed, 243 insertions(+), 308 deletions(-) create mode 100644 mobile/android/modules/geckoview/metrics.yaml diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index a16737e64008..13fbe2940c07 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -230,10 +230,8 @@ void WindowGlobalParent::OriginCounter::UpdateSiteOriginsFrom( } void WindowGlobalParent::OriginCounter::Accumulate() { - mozilla::Telemetry::Accumulate( - mozilla::Telemetry::HistogramID:: - FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_DOCUMENT, - mMaxOrigins); + mozilla::glean::geckoview::per_document_site_origins.AccumulateSamples( + {mMaxOrigins}); mMaxOrigins = 0; mOriginMap.Clear(); diff --git a/mobile/android/chrome/geckoview/geckoview.js b/mobile/android/chrome/geckoview/geckoview.js index b134c6c1fcf8..6dc5ed4610df 100644 --- a/mobile/android/chrome/geckoview/geckoview.js +++ b/mobile/android/chrome/geckoview/geckoview.js @@ -18,7 +18,6 @@ ChromeUtils.defineESModuleGetters(this, { GeckoViewActorManager: "resource://gre/modules/GeckoViewActorManager.sys.mjs", GeckoViewSettings: "resource://gre/modules/GeckoViewSettings.sys.mjs", GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.sys.mjs", - HistogramStopwatch: "resource://gre/modules/GeckoViewTelemetry.sys.mjs", InitializationTracker: "resource://gre/modules/GeckoViewTelemetry.sys.mjs", RemoteSecuritySettings: "resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs", @@ -54,13 +53,6 @@ var ModuleManager = { }, init(aBrowser, aModules) { - const MODULES_INIT_PROBE = new HistogramStopwatch( - "GV_STARTUP_MODULES_MS", - aBrowser - ); - - MODULES_INIT_PROBE.start(); - const initData = this._initData; this._browser = aBrowser; this._settings = initData.settings; @@ -121,8 +113,6 @@ var ModuleManager = { this._modules.clear(); }); - - MODULES_INIT_PROBE.finish(); }, onPrintWindow(aParams) { diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteManager.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteManager.java index 0385b0b0e6e5..7a2e74c9afba 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteManager.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteManager.java @@ -17,7 +17,6 @@ import java.util.LinkedList; import java.util.List; import java.util.NoSuchElementException; import org.mozilla.gecko.GeckoAppShell; -import org.mozilla.gecko.TelemetryUtils; import org.mozilla.gecko.gfx.GeckoSurface; public final class RemoteManager implements IBinder.DeathRecipient { @@ -172,7 +171,6 @@ public final class RemoteManager implements IBinder.DeathRecipient { @Override public void binderDied() { Log.e(LOGTAG, "remote codec is dead"); - TelemetryUtils.addToHistogram("MEDIA_DECODING_PROCESS_CRASH", 1); handleRemoteDeath(); } diff --git a/mobile/android/modules/geckoview/GeckoViewProgress.sys.mjs b/mobile/android/modules/geckoview/GeckoViewProgress.sys.mjs index 8e7c2117f0e1..66aceb974cf9 100644 --- a/mobile/android/modules/geckoview/GeckoViewProgress.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewProgress.sys.mjs @@ -23,7 +23,7 @@ XPCOMUtils.defineLazyServiceGetter( ChromeUtils.defineESModuleGetters(lazy, { BrowserTelemetryUtils: "resource://gre/modules/BrowserTelemetryUtils.sys.mjs", - HistogramStopwatch: "resource://gre/modules/GeckoViewTelemetry.sys.mjs", + GleanStopwatch: "resource://gre/modules/GeckoViewTelemetry.sys.mjs", }); var IdentityHandler = { @@ -180,15 +180,15 @@ class Tracker { class ProgressTracker extends Tracker { constructor(aModule) { super(aModule); - const window = aModule.browser.ownerGlobal; - this.pageLoadProbe = new lazy.HistogramStopwatch("GV_PAGE_LOAD_MS", window); - this.pageReloadProbe = new lazy.HistogramStopwatch( - "GV_PAGE_RELOAD_MS", - window + + this.pageLoadStopwatch = new lazy.GleanStopwatch( + Glean.geckoview.pageLoadTime ); - this.pageLoadProgressProbe = new lazy.HistogramStopwatch( - "GV_PAGE_LOAD_PROGRESS_MS", - window + this.pageReloadStopwatch = new lazy.GleanStopwatch( + Glean.geckoview.pageReloadTime + ); + this.pageLoadProgressStopwatch = new lazy.GleanStopwatch( + Glean.geckoview.pageLoadProgressTime ); this.clear(); @@ -212,7 +212,7 @@ class ProgressTracker extends Tracker { return; } - this.pageLoadProgressProbe.start(); + this.pageLoadProgressStopwatch.start(); data.uri = aUri; data.pageStart = true; @@ -236,9 +236,9 @@ class ProgressTracker extends Tracker { } if (aIsSuccess) { - this.pageLoadProgressProbe.finish(); + this.pageLoadProgressStopwatch.finish(); } else { - this.pageLoadProgressProbe.cancel(); + this.pageLoadProgressStopwatch.cancel(); } const data = this._data; @@ -265,7 +265,9 @@ class ProgressTracker extends Tracker { const isPageReload = (aWebProgress.loadType & Ci.nsIDocShell.LOAD_CMD_RELOAD) != 0; - const probe = isPageReload ? this.pageReloadProbe : this.pageLoadProbe; + const stopwatch = isPageReload + ? this.pageReloadStopwatch + : this.pageLoadStopwatch; const isStart = (aStateFlags & Ci.nsIWebProgressListener.STATE_START) != 0; const isStop = (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) != 0; @@ -273,13 +275,13 @@ class ProgressTracker extends Tracker { (aStateFlags & Ci.nsIWebProgressListener.STATE_REDIRECTING) != 0; if (isStart) { - probe.start(); + stopwatch.start(); this.start(displaySpec); } else if (isStop && !aWebProgress.isLoadingDocument) { - probe.finish(); + stopwatch.finish(); this.stop(aStatus == Cr.NS_OK); } else if (isRedirecting) { - probe.start(); + stopwatch.start(); this.start(displaySpec); } diff --git a/mobile/android/modules/geckoview/GeckoViewTelemetry.sys.mjs b/mobile/android/modules/geckoview/GeckoViewTelemetry.sys.mjs index 623caa8975dc..bb7074ced8cf 100644 --- a/mobile/android/modules/geckoview/GeckoViewTelemetry.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewTelemetry.sys.mjs @@ -15,33 +15,30 @@ export var InitializationTracker = { }, }; -// A helper for histogram timer probes. -export class HistogramStopwatch { - constructor(aName, aAssociated) { - this._name = aName; - this._obj = aAssociated; +// A helper for timing_distribution metrics. +export class GleanStopwatch { + constructor(aTimingDistribution) { + this._metric = aTimingDistribution; } isRunning() { - return TelemetryStopwatch.running(this._name, this._obj); + return !!this._timerId; } start() { if (this.isRunning()) { this.cancel(); } - TelemetryStopwatch.start(this._name, this._obj); + this._timerId = this._metric.start(); } finish() { - TelemetryStopwatch.finish(this._name, this._obj); + this._metric.stopAndAccumulate(this._timerId); + this._timerId = null; } cancel() { - TelemetryStopwatch.cancel(this._name, this._obj); - } - - timeElapsed() { - return TelemetryStopwatch.timeElapsed(this._name, this._obj, false); + this._metric.cancel(this._timerId); + this._timerId = null; } } diff --git a/mobile/android/modules/geckoview/metrics.yaml b/mobile/android/modules/geckoview/metrics.yaml new file mode 100644 index 000000000000..3b8cdd0dc949 --- /dev/null +++ b/mobile/android/modules/geckoview/metrics.yaml @@ -0,0 +1,153 @@ +# 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: + - "GeckoView :: General" + +geckoview: + page_load_progress_time: + type: timing_distribution + time_unit: millisecond + telemetry_mirror: GV_PAGE_LOAD_PROGRESS_MS + description: > + Time between page load progress starts (0) and completion (100). + (Migrated from the geckoview metric of the same name). + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1499418 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1580077 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1877576 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1580077#c10 + notification_emails: + - android-probes@mozilla.com + expires: never + + page_load_time: + type: timing_distribution + time_unit: millisecond + telemetry_mirror: GV_PAGE_LOAD_MS + description: > + The time taken to load a page. This includes all static contents, no + dynamic content. + Loading of about: pages is not counted. + Back back navigation (sometimes via BFCache) is included which is a + source of bimodality due to the <50ms load times. + (Migrated from the geckoview metric of the same name). + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1499418 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1584109 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1877576 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1 + notification_emails: + - android-probes@mozilla.com + expires: never + + page_reload_time: + type: timing_distribution + time_unit: millisecond + telemetry_mirror: GV_PAGE_RELOAD_MS + description: > + Time taken to reload a page. + This includes all static contents, no dynamic content. + Loading of about: pages is not counted. + (Migrated from the geckoview metric of the same name). + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1549519 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1580077 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1877576 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1580077#c10 + notification_emails: + - android-probes@mozilla.com + - sefeng@mozilla.com + - perf-telemetry-alerts@mozilla.com + expires: never + + document_site_origins: + type: custom_distribution + description: > + When a document is loaded, report the + number of [site origins](https://searchfox.org/ + mozilla-central/rev/ + 3300072e993ae05d50d5c63d815260367eaf9179/ + caps/nsIPrincipal.idl#264) of the entire browser + if it has been at least 5 minutes since last + time we collect this data. + (Migrated from the geckoview metric of the same name). + range_min: 0 + range_max: 100 + bucket_count: 50 + histogram_type: exponential + unit: number of site_origin + telemetry_mirror: FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_ALL_TABS + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1589700 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1877576 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1589700#c5 + notification_emails: + - sefeng@mozilla.com + - perf-telemetry-alerts@mozilla.com + expires: never + + per_document_site_origins: + type: custom_distribution + description: > + When a document is unloaded, report the highest number of + [site origins](https://searchfox.org/ + mozilla-central/rev/ + 3300072e993ae05d50d5c63d815260367eaf9179/ + caps/nsIPrincipal.idl#264) loaded simultaneously in that + document. + (Migrated from the geckoview metric of the same name). + range_min: 0 + range_max: 100 + bucket_count: 50 + histogram_type: exponential + unit: number of site origins per document + telemetry_mirror: FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_DOCUMENT + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1603185 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1877576 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1603185#c13 + notification_emails: + - barret@mozilla.com + - perf-telemetry-alerts@mozilla.com + expires: never + + startup_runtime: + type: timing_distribution + time_unit: millisecond + description: > + The time taken to initialize GeckoRuntime. + (Migrated from the geckoview metric of the same name). + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1499418 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1584109 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1 + notification_emails: + - android-probes@mozilla.com + expires: never + + content_process_lifetime: + type: timing_distribution + time_unit: millisecond + description: > + The uptime of content processes. + (Migrated from the geckoview metric of the same name). + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1625325 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1625325#c2 + notification_emails: + - android-probes@mozilla.com + expires: never diff --git a/toolkit/components/glean/metrics_index.py b/toolkit/components/glean/metrics_index.py index 9b601aa03c64..2102b0db3f83 100644 --- a/toolkit/components/glean/metrics_index.py +++ b/toolkit/components/glean/metrics_index.py @@ -23,6 +23,7 @@ gecko_metrics = [ "gfx/metrics.yaml", "image/decoders/metrics.yaml", "mobile/android/actors/metrics.yaml", + "mobile/android/modules/geckoview/metrics.yaml", "netwerk/metrics.yaml", "netwerk/protocol/http/metrics.yaml", "security/manager/ssl/metrics.yaml", @@ -38,6 +39,7 @@ gecko_metrics = [ "toolkit/components/translations/metrics.yaml", "toolkit/mozapps/extensions/metrics.yaml", "toolkit/mozapps/handling/metrics.yaml", + "toolkit/xre/metrics.yaml", "xpcom/metrics.yaml", ] @@ -63,7 +65,6 @@ firefox_desktop_metrics = [ "toolkit/components/telemetry/dap/metrics.yaml", "toolkit/components/telemetry/metrics.yaml", "toolkit/modules/metrics.yaml", - "toolkit/xre/metrics.yaml", "widget/cocoa/metrics.yaml", "widget/windows/metrics.yaml", ] diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 2f112766e819..6dee45d78dde 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -8665,7 +8665,7 @@ }, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_ALL_TABS": { "record_in_processes": ["main"], - "products": ["firefox", "geckoview_streaming"], + "products": ["firefox"], "expires_in_version": "never", "kind": "exponential", "high": 100, @@ -8677,7 +8677,7 @@ }, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_DOCUMENT": { "record_in_processes": ["main"], - "products": ["firefox", "geckoview_streaming"], + "products": ["firefox"], "expires_in_version": "never", "kind": "exponential", "high": 100, @@ -11335,16 +11335,6 @@ "n_values": 5, "description": "Counts the number of entries in the sample description box (stsd) for a track in an mp4. Recorded each time we process a track's metadata while parsing mp4s." }, - "MEDIA_DECODING_PROCESS_CRASH": { - "record_in_processes": ["content"], - "products": ["firefox"], - "alert_emails": ["media-alerts@mozilla.com"], - "bug_numbers": [1304268], - "expires_in_version": "never", - "kind": "count", - "operating_systems": ["android"], - "description": "Records a value each time GeckoView remote decoding process crashes unexpectedly while decoding media content." - }, "MEDIA_AUDIO_INIT_FAILURE": { "record_in_processes": ["main", "content"], "products": ["firefox"], @@ -17411,20 +17401,9 @@ "alert_emails": ["jvarga@mozilla.com", "storage-telemetry@mozilla.com"], "description": "Time (ms) for the QuotaManager to shutdown. Keyed by conditions during shutdown, see RecordTimeDeltaHelper::Run in https://searchfox.org/mozilla-central/source/dom/quota/ActorsParent.cpp" }, - "GV_CONTENT_PROCESS_LIFETIME_MS": { - "record_in_processes": ["main"], - "products": ["geckoview_streaming"], - "alert_emails": ["geckoview-team@mozilla.com", "asferro@mozilla.com"], - "expires_in_version": "never", - "kind": "exponential", - "high": 3600000, - "n_buckets": 100, - "bug_numbers": [1625325], - "description": "GeckoView: The uptime of content processes in ms" - }, "GV_PAGE_LOAD_PROGRESS_MS": { "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec", "geckoview_streaming"], + "products": ["firefox"], "alert_emails": ["geckoview-team@mozilla.com", "esawin@mozilla.com"], "expires_in_version": "never", "kind": "exponential", @@ -17435,7 +17414,7 @@ }, "GV_PAGE_LOAD_MS": { "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec", "geckoview_streaming"], + "products": ["firefox"], "alert_emails": ["geckoview-team@mozilla.com", "esawin@mozilla.com"], "expires_in_version": "never", "kind": "exponential", @@ -17446,7 +17425,7 @@ }, "GV_PAGE_RELOAD_MS": { "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec", "geckoview_streaming"], + "products": ["firefox"], "alert_emails": [ "geckoview-team@mozilla.com", "sefeng@mozilla.com", @@ -17459,28 +17438,6 @@ "bug_numbers": [1549519, 1580077], "description": "GeckoView: Time taken to reload a page in ms. This includes all static contents, no dynamic content. Loading of about: pages is not counted." }, - "GV_STARTUP_RUNTIME_MS": { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec", "geckoview_streaming"], - "alert_emails": ["geckoview-team@mozilla.com", "esawin@mozilla.com"], - "expires_in_version": "never", - "kind": "exponential", - "high": 10000, - "n_buckets": 50, - "bug_numbers": [1499418, 1584109], - "description": "GeckoView: Time taken to initialize GeckoRuntime in ms." - }, - "GV_STARTUP_MODULES_MS": { - "record_in_processes": ["main"], - "products": ["firefox", "fennec"], - "alert_emails": ["geckoview-team@mozilla.com", "esawin@mozilla.com"], - "expires_in_version": "never", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "bug_numbers": [1499418], - "description": "GeckoView: Time taken to initialize all GeckoView modules in ms." - }, "HTTP_TRAFFIC_ANALYSIS_3": { "record_in_processes": ["main"], "products": ["firefox", "fennec"], diff --git a/toolkit/components/telemetry/Scalars.yaml b/toolkit/components/telemetry/Scalars.yaml index aa4eba8e53ce..66a8b787e791 100644 --- a/toolkit/components/telemetry/Scalars.yaml +++ b/toolkit/components/telemetry/Scalars.yaml @@ -1439,42 +1439,6 @@ cookie.banners.click: - 'content' release_channel_collection: opt-out -gecko: - version: - bug_numbers: - - 1611240 - description: > - The version of the Gecko engine, example: '74.0a1'. - It consists of the major and minor version, followed by the release life cycle phase. - 'a' stands for alpha or nightly, 'b' stands for beta. - The number behind the release life cycle phase indicates minor releases within the phase. - expires: never - kind: string - notification_emails: - - gfx-telemetry-alerts@mozilla.com - - ktaeleman@mozilla.com - products: - - 'geckoview_streaming' - record_in_processes: - - 'main' - release_channel_collection: opt-out - build_id: - bug_numbers: - - 1611240 - description: > - The build id of the Gecko engine, example: '20200205124310'. - It contains the time the build was created and is used as a unique id for the build. - expires: never - kind: string - notification_emails: - - gfx-telemetry-alerts@mozilla.com - - ktaeleman@mozilla.com - products: - - 'geckoview_streaming' - record_in_processes: - - 'main' - release_channel_collection: opt-out - extensions.apis.dnr: startup_cache_entries: bug_numbers: diff --git a/toolkit/components/telemetry/geckoview/streaming/metrics.yaml b/toolkit/components/telemetry/geckoview/streaming/metrics.yaml index baae1f6e574f..42af4d5c11db 100644 --- a/toolkit/components/telemetry/geckoview/streaming/metrics.yaml +++ b/toolkit/components/telemetry/geckoview/streaming/metrics.yaml @@ -12,174 +12,6 @@ --- $schema: moz://mozilla.org/schemas/glean/metrics/2-0-0 -geckoview: - version: - description: > - The version of the Gecko engine, example: 74.0a1 - type: string - # Temporary misuse of the user lifetime approved by Glean team - # due to limitations in Geckoview streaming telemetry. - # DO NOT DUPLICATE unless approved by Glean team. - lifetime: user - gecko_datapoint: gecko.version - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1611240 - - https://bugzilla.mozilla.org/show_bug.cgi?id=1687219 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1611240#c2 - notification_emails: - - gfx-telemetry-alerts@mozilla.com - expires: never - - build_id: - description: > - The Buildid of the Gecko engine, example: 20200205124310 - type: string - # Temporary misuse of the user lifetime approved by Glean team - # due to limitations in Geckoview streaming telemetry. - # DO NOT DUPLICATE unless approved by Glean team. - lifetime: user - gecko_datapoint: gecko.build_id - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1611240 - - https://bugzilla.mozilla.org/show_bug.cgi?id=1687219 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1611240#c2 - notification_emails: - - gfx-telemetry-alerts@mozilla.com - expires: never - - content_process_lifetime: - type: timing_distribution - time_unit: millisecond - gecko_datapoint: GV_CONTENT_PROCESS_LIFETIME_MS - description: > - The uptime of content processes in ms - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1625325 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1625325#c2 - notification_emails: - - android-probes@mozilla.com - expires: never - - page_load_progress_time: - type: timing_distribution - time_unit: millisecond - gecko_datapoint: GV_PAGE_LOAD_PROGRESS_MS - description: > - Time between page load progress starts (0) and completion (100). - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1499418 - - https://bugzilla.mozilla.org/show_bug.cgi?id=1580077 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1580077#c10 - notification_emails: - - android-probes@mozilla.com - expires: never - - page_load_time: - type: timing_distribution - time_unit: millisecond - gecko_datapoint: GV_PAGE_LOAD_MS - description: > - The time taken to load a page. This includes all static contents, no - dynamic content. - Loading of about: pages is not counted. - Back back navigation (sometimes via BFCache) is included which is a - source of bimodality due to the <50ms load times. - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1499418 - - https://bugzilla.mozilla.org/show_bug.cgi?id=1584109 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1 - notification_emails: - - android-probes@mozilla.com - expires: never - - page_reload_time: - type: timing_distribution - time_unit: millisecond - gecko_datapoint: GV_PAGE_RELOAD_MS - description: > - Time taken to reload a page. - This includes all static contents, no dynamic content. - Loading of about: pages is not counted. - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1549519 - - https://bugzilla.mozilla.org/show_bug.cgi?id=1580077 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1580077#c10 - notification_emails: - - android-probes@mozilla.com - - sefeng@mozilla.com - - perf-telemetry-alerts@mozilla.com - expires: never - - startup_runtime: - type: timing_distribution - time_unit: millisecond - gecko_datapoint: GV_STARTUP_RUNTIME_MS - description: > - The time taken to initialize GeckoRuntime. - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1499418 - - https://bugzilla.mozilla.org/show_bug.cgi?id=1584109 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1 - notification_emails: - - android-probes@mozilla.com - expires: never - - document_site_origins: - type: custom_distribution - description: > - When a document is loaded, report the - number of [site origins](https://searchfox.org/ - mozilla-central/rev/ - 3300072e993ae05d50d5c63d815260367eaf9179/ - caps/nsIPrincipal.idl#264) of the entire browser - if it has been at least 5 minutes since last - time we collect this data. - range_min: 0 - range_max: 100 - bucket_count: 50 - histogram_type: exponential - unit: number of site_origin - gecko_datapoint: FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_ALL_TABS - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1589700 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1589700#c5 - notification_emails: - - sefeng@mozilla.com - - perf-telemetry-alerts@mozilla.com - expires: never - - per_document_site_origins: - type: custom_distribution - description: > - When a document is unloaded, report the highest number of - [site origins](https://searchfox.org/ - mozilla-central/rev/ - 3300072e993ae05d50d5c63d815260367eaf9179/ - caps/nsIPrincipal.idl#264) loaded simultaneously in that - document. - range_min: 0 - range_max: 100 - bucket_count: 50 - histogram_type: exponential - unit: number of site origins per document - gecko_datapoint: FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_DOCUMENT - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1603185 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1603185#c13 - notification_emails: - - barret@mozilla.com - - perf-telemetry-alerts@mozilla.com - expires: never - performance.pageload: load_time: type: timing_distribution diff --git a/toolkit/modules/BrowserTelemetryUtils.sys.mjs b/toolkit/modules/BrowserTelemetryUtils.sys.mjs index efbbe0146776..c3035974e86e 100644 --- a/toolkit/modules/BrowserTelemetryUtils.sys.mjs +++ b/toolkit/modules/BrowserTelemetryUtils.sys.mjs @@ -56,9 +56,6 @@ export var BrowserTelemetryUtils = { } let originCount = this.computeSiteOriginCount(aWindows, aIsGeckoView); - let histogram = Services.telemetry.getHistogramById( - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_ALL_TABS" - ); // Discard the first load because most of the time the first load only has 1 // tab and 1 window open, so it is useless to report it. @@ -67,7 +64,7 @@ export var BrowserTelemetryUtils = { } else if (currentTime >= this._lastRecordSiteOrigin + this.min_interval) { this._lastRecordSiteOrigin = currentTime; - histogram.add(originCount); + Glean.geckoview.documentSiteOrigins.accumulateSamples([originCount]); } }, }; diff --git a/toolkit/xre/metrics.yaml b/toolkit/xre/metrics.yaml index c53ee95ecd8e..03a8dfe3fdc8 100644 --- a/toolkit/xre/metrics.yaml +++ b/toolkit/xre/metrics.yaml @@ -9,3 +9,42 @@ $schema: moz://mozilla.org/schemas/glean/metrics/2-0-0 $tags: - "Toolkit :: Startup and Profile System" + +gecko: + version: + description: > + The version of the Gecko engine, example: 74.0a1 + (Migrated from the geckoview metric of the same name). + type: string + # Temporary misuse of the user lifetime approved by Glean team + # due to limitations in Geckoview streaming telemetry. + # DO NOT DUPLICATE unless approved by Glean team. + lifetime: user + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1611240 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1687219 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1877576 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1611240#c2 + notification_emails: + - gfx-telemetry-alerts@mozilla.com + expires: never + + build_id: + description: > + The Buildid of the Gecko engine, example: 20200205124310 + (Migrated from the geckoview metric of the same name). + type: string + # Temporary misuse of the user lifetime approved by Glean team + # due to limitations in Geckoview streaming telemetry. + # DO NOT DUPLICATE unless approved by Glean team. + lifetime: user + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1611240 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1687219 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1877576 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1611240#c2 + notification_emails: + - gfx-telemetry-alerts@mozilla.com + expires: never diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 495f3bc2fd6b..230d0da3e75f 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -36,6 +36,7 @@ #include "mozilla/intl/LocaleService.h" #include "mozilla/JSONWriter.h" #include "mozilla/gfx/gfxVars.h" +#include "mozilla/glean/GleanMetrics.h" #include "mozilla/glean/GleanPings.h" #include "mozilla/widget/TextRecognition.h" #include "BaseProfiler.h" @@ -5656,10 +5657,8 @@ nsresult XREMain::XRE_mainRun() { #endif /* MOZ_INSTRUMENT_EVENT_LOOP */ // Send Telemetry about Gecko version and buildid - Telemetry::ScalarSet(Telemetry::ScalarID::GECKO_VERSION, - NS_ConvertASCIItoUTF16(gAppData->version)); - Telemetry::ScalarSet(Telemetry::ScalarID::GECKO_BUILD_ID, - NS_ConvertASCIItoUTF16(gAppData->buildID)); + mozilla::glean::gecko::version.Set(nsDependentCString(gAppData->version)); + mozilla::glean::gecko::build_id.Set(nsDependentCString(gAppData->buildID)); #if defined(MOZ_SANDBOX) && defined(XP_LINUX) // If we're on Linux, we now have information about the OS capabilities diff --git a/widget/android/Telemetry.h b/widget/android/Telemetry.h index 9936b1336792..ea8f2dd41803 100644 --- a/widget/android/Telemetry.h +++ b/widget/android/Telemetry.h @@ -10,7 +10,8 @@ #include "nsAppShell.h" #include "nsIAndroidBridge.h" -#include "mozilla/Telemetry.h" +#include "mozilla/TimeStamp.h" +#include "mozilla/glean/GleanMetrics.h" namespace mozilla { namespace widget { @@ -21,7 +22,14 @@ class Telemetry final : public java::TelemetryUtils::Natives { public: static void AddHistogram(jni::String::Param aName, int32_t aValue) { MOZ_ASSERT(aName); - mozilla::Telemetry::Accumulate(aName->ToCString().get(), aValue); + nsCString name = aName->ToCString(); + if (name.EqualsLiteral("GV_STARTUP_RUNTIME_MS")) { + glean::geckoview::startup_runtime.AccumulateRawDuration( + TimeDuration::FromMilliseconds(aValue)); + } else if (name.EqualsLiteral("GV_CONTENT_PROCESS_LIFETIME_MS")) { + glean::geckoview::content_process_lifetime.AccumulateRawDuration( + TimeDuration::FromMilliseconds(aValue)); + } } };