diff --git a/browser/components/search/test/browser/telemetry/browser_search_telemetry_domain_categorization_ping_submission.js b/browser/components/search/test/browser/telemetry/browser_search_telemetry_domain_categorization_ping_submission.js index 0196483b8c9d..f3e7edd1c137 100644 --- a/browser/components/search/test/browser/telemetry/browser_search_telemetry_domain_categorization_ping_submission.js +++ b/browser/components/search/test/browser/telemetry/browser_search_telemetry_domain_categorization_ping_submission.js @@ -82,7 +82,10 @@ add_setup(async function () { let promise = waitForDomainToCategoriesUpdate(); await insertRecordIntoCollectionAndSync(); await SpecialPowers.pushPrefEnv({ - set: [["browser.search.serpEventTelemetryCategorization.enabled", true]], + set: [ + ["browser.search.serpEventTelemetryCategorization.enabled", true], + ["telemetry.fog.test.activity_limit", 120], + ], }); await promise; diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index bf0b349b05bc..788d72a27f71 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -15343,13 +15343,13 @@ rust: true - name: telemetry.fog.test.activity_limit - type: RelaxedAtomicUint32 + type: RelaxedAtomicInt32 value: 120 mirror: always rust: true - name: telemetry.fog.test.inactivity_limit - type: RelaxedAtomicUint32 + type: RelaxedAtomicInt32 value: 1200 mirror: always rust: true diff --git a/testing/gtest/mozilla/GTestRunner.cpp b/testing/gtest/mozilla/GTestRunner.cpp index 278bfdf80a1d..b899d9348374 100644 --- a/testing/gtest/mozilla/GTestRunner.cpp +++ b/testing/gtest/mozilla/GTestRunner.cpp @@ -161,6 +161,11 @@ int RunGTestFunc(int* argc, char** argv) { // However, at init, Glean may decide to send a ping. So let's first tell FOG // that these pings shouldn't actually be uploaded. Preferences::SetInt("telemetry.fog.test.localhost_port", -1); + // Though the default user-activity limits ought to be longer than a test, + // ensure that they don't trigger unnecessary ping submission (which clears + // storage, making it hard to test instrumentation). + Preferences::SetInt("telemetry.fog.test.activity_limit", -1); + Preferences::SetInt("telemetry.fog.test.inactivity_limit", -1); const nsCString empty; RefPtr(FOG::GetSingleton())->InitializeFOG(empty, empty, false); diff --git a/testing/profiles/common/user.js b/testing/profiles/common/user.js index 6f111b6d6eef..af81b3c540c2 100644 --- a/testing/profiles/common/user.js +++ b/testing/profiles/common/user.js @@ -79,9 +79,12 @@ user_pref("browser.newtabpage.activity-stream.discoverystream.region-weather-con user_pref("browser.newtabpage.activity-stream.newtabWallpapers.enabled", false); // Don't pull sponsored Top Sites content from the network user_pref("browser.newtabpage.activity-stream.showSponsoredTopSites", false); -// Default Glean to "record but don't report" mode. Docs: +// Default Glean to "record but don't report" mode, and to never trigger +// activity-based ping submission. Docs: // https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/preferences.html user_pref("telemetry.fog.test.localhost_port", -1); +user_pref("telemetry.fog.test.activity_limit", -1); +user_pref("telemetry.fog.test.inactivity_limit", -1); // Disable overlay scrollbars on GTK for testing. A bunch of tests (specially // mochitests) assume scrollbars take space. We disable them on macOS (where // overlay is also the default) at the system level as well, so this is diff --git a/testing/profiles/perf/user.js b/testing/profiles/perf/user.js index f417d15077f6..89d8b0501255 100644 --- a/testing/profiles/perf/user.js +++ b/testing/profiles/perf/user.js @@ -79,7 +79,12 @@ user_pref("security.enable_java", false); user_pref("security.external_protocol_requires_permission", false); user_pref("security.fileuri.strict_origin_policy", false); user_pref("toolkit.telemetry.server", "https://127.0.0.1/telemetry-dummy/"); +// Default Glean to "record but don't report" mode, and to never trigger +// activity-based ping submission. Docs: +// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/preferences.html user_pref("telemetry.fog.test.localhost_port", -1); +user_pref("telemetry.fog.test.activity_limit", -1); +user_pref("telemetry.fog.test.inactivity_limit", -1); // The telemetry system sometimes uses a separate program to send telemetry // pings, particularly in the case when Firefox is shutting down. The prefs above // prevent telemetry from being sent anywhere useful, but even so the process would diff --git a/testing/profiles/raptor-android/user.js b/testing/profiles/raptor-android/user.js index 2e319cbca757..770d563312e2 100644 --- a/testing/profiles/raptor-android/user.js +++ b/testing/profiles/raptor-android/user.js @@ -13,7 +13,12 @@ user_pref("browser.cache.disk.smart_size.enabled", true); user_pref("extensions.webextensions.warnings-as-errors", false); // disable telemetry bug 1639148 user_pref("toolkit.telemetry.server", ""); +// Default Glean to "record but don't report" mode, and to never trigger +// activity-based ping submission. Docs: +// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/preferences.html user_pref("telemetry.fog.test.localhost_port", -1); +user_pref("telemetry.fog.test.activity_limit", -1); +user_pref("telemetry.fog.test.inactivity_limit", -1); // Turn off update user_pref("app.update.disabledForTesting", true); diff --git a/testing/profiles/reftest/user.js b/testing/profiles/reftest/user.js index 62ac3048c4f2..0a4d220838fb 100644 --- a/testing/profiles/reftest/user.js +++ b/testing/profiles/reftest/user.js @@ -85,7 +85,12 @@ user_pref("testing.supports.moz-bool-pref", false); // server in the middle of the tests. user_pref("toolkit.telemetry.enabled", false); user_pref("toolkit.telemetry.server", "https://%(server)s/telemetry-dummy/"); +// Default Glean to "record but don't report" mode, and to never trigger +// activity-based ping submission. Docs: +// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/preferences.html user_pref("telemetry.fog.test.localhost_port", -1); +user_pref("telemetry.fog.test.activity_limit", -1); +user_pref("telemetry.fog.test.inactivity_limit", -1); user_pref("ui.caretBlinkTime", -1); user_pref("ui.caretWidth", 1); user_pref("ui.prefersReducedMotion", 0); diff --git a/testing/profiles/unittest-required/user.js b/testing/profiles/unittest-required/user.js index 2bdd839edcb6..9c56a34289f3 100644 --- a/testing/profiles/unittest-required/user.js +++ b/testing/profiles/unittest-required/user.js @@ -202,7 +202,12 @@ user_pref("toolkit.telemetry.firstShutdownPing.enabled", false); user_pref("toolkit.telemetry.newProfilePing.enabled", false); // We want to collect telemetry, but we don't want to send in the results. user_pref("toolkit.telemetry.server", "https://{server}/telemetry-dummy/"); +// Default Glean to "record but don't report" mode, and to never trigger +// activity-based ping submission. Docs: +// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/preferences.html user_pref("telemetry.fog.test.localhost_port", -1); +user_pref("telemetry.fog.test.activity_limit", -1); +user_pref("telemetry.fog.test.inactivity_limit", -1); // Don't send the 'shutdown' ping using the pingsender on the first session using // the 'pingsender' process. Valgrind marks the process as leaky (e.g. see bug 1364068 // for the 'new-profile' ping) but does not provide enough information diff --git a/testing/profiles/xpcshell/user.js b/testing/profiles/xpcshell/user.js index a4918d6abcd8..47734e7ff062 100644 --- a/testing/profiles/xpcshell/user.js +++ b/testing/profiles/xpcshell/user.js @@ -18,7 +18,12 @@ user_pref("geo.provider.network.compare.url", ""); user_pref("media.gmp-manager.updateEnabled", false); user_pref("media.gmp-manager.url.override", "http://%(server)s/dummy-gmp-manager.xml"); user_pref("toolkit.telemetry.server", "https://%(server)s/telemetry-dummy"); +// Default Glean to "record but don't report" mode, and to never trigger +// activity-based ping submission. Docs: +// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/preferences.html user_pref("telemetry.fog.test.localhost_port", -1); +user_pref("telemetry.fog.test.activity_limit", -1); +user_pref("telemetry.fog.test.inactivity_limit", -1); // Prevent Remote Settings to issue non local connections. user_pref("services.settings.server", "data:,#remote-settings-dummy/v1"); // Prevent intermediate preloads to be downloaded on Remote Settings polling. diff --git a/toolkit/components/glean/docs/dev/preferences.md b/toolkit/components/glean/docs/dev/preferences.md index 732e25c5c9bf..070dce7fe1a2 100644 --- a/toolkit/components/glean/docs/dev/preferences.md +++ b/toolkit/components/glean/docs/dev/preferences.md @@ -36,6 +36,7 @@ This pair of prefs control the length of time of activity before inactivity needed before FOG informs the SDK's Client Activity API that the client was (in)active. Present to allow testing without figuring out how to mock Rust's clock. Their values are integer seconds. +The value `-1` is treated as no limit (never trigger (in)activity). Defaults to 120 (activity), 1200 (inactivity). ## Internal Preferences @@ -51,7 +52,7 @@ If true, [JOG](./jog) is enabled so that artifact builds will exhibit changes to If set, and `GLEAN_SOURCE_TAGS` isn't set, FOG will set a [Glean source tag](https://mozilla.github.io/glean/book/reference/debug/sourceTags.html) -of `automation`. +of `automation` and FOG will disable the submission of "metrics" pings. If `GLEAN_SOURCE_TAGS` is set, the `automation` source tag will not be added automatically. diff --git a/toolkit/components/glean/docs/dev/testing.md b/toolkit/components/glean/docs/dev/testing.md index fe6c3e0fe763..eba73a51414f 100644 --- a/toolkit/components/glean/docs/dev/testing.md +++ b/toolkit/components/glean/docs/dev/testing.md @@ -20,7 +20,7 @@ To run all the things, here's the tl;dr: && python3 ./mach python-test toolkit/components/glean/tests/pytest && ./mach test toolkit/components/glean/tests/xpcshell && ./mach telemetry-tests-client toolkit/components/telemetry/tests/marionette/tests/client/test_fog* --gecko-log "-" -&& ./mach test toolkit/components/glean/tests/browser +&& ./mach test toolkit/components/glean/tests/browser --headless ` ## Logging diff --git a/toolkit/components/glean/src/init/user_activity.rs b/toolkit/components/glean/src/init/user_activity.rs index dbafeca4e864..ff952869aa5e 100644 --- a/toolkit/components/glean/src/init/user_activity.rs +++ b/toolkit/components/glean/src/init/user_activity.rs @@ -2,6 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. +use std::convert::TryInto; use std::ffi::CStr; use std::os::raw::c_char; use std::sync::{ @@ -90,7 +91,7 @@ impl UserActivityObserver { .elapsed(); // We only care after a certain period of inactivity (default 20min). let limit = static_prefs::pref!("telemetry.fog.test.inactivity_limit"); - if inactivity >= Duration::from_secs(limit.into()) { + if limit >= 0 && inactivity >= Duration::from_secs(limit.try_into().unwrap_or(0)) { log::info!( "User triggers core activity after {}s!", inactivity.as_secs() @@ -114,7 +115,7 @@ impl UserActivityObserver { .elapsed(); // We only care after a certain period of activity (default 2min). let limit = static_prefs::pref!("telemetry.fog.test.activity_limit"); - if activity >= Duration::from_secs(limit.into()) { + if limit >= 0 && activity >= Duration::from_secs(limit.try_into().unwrap_or(0)) { log::info!( "User triggers core inactivity after {}s!", activity.as_secs()