Bug 1855257 - Add a flag to disable internal pings r=chutten

Differential Revision: https://phabricator.services.mozilla.com/D201078
This commit is contained in:
Jan-Erik Rediger 2024-04-11 15:41:02 +00:00
Родитель 087fce93d4
Коммит 7855893216
4 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -162,7 +162,7 @@ int RunGTestFunc(int* argc, char** argv) {
// that these pings shouldn't actually be uploaded.
Preferences::SetInt("telemetry.fog.test.localhost_port", -1);
const nsCString empty;
RefPtr<FOG>(FOG::GetSingleton())->InitializeFOG(empty, empty);
RefPtr<FOG>(FOG::GetSingleton())->InitializeFOG(empty, empty, false);
return RUN_ALL_TESTS();
}

Просмотреть файл

@ -38,6 +38,7 @@ use viaduct_uploader::ViaductUploader;
pub extern "C" fn fog_init(
data_path_override: &nsACString,
app_id_override: &nsACString,
disable_internal_pings: bool,
) -> nsresult {
let upload_enabled = static_prefs::pref!("datareporting.healthreport.uploadEnabled");
let recording_enabled = static_prefs::pref!("telemetry.fog.test.localhost_port") < 0;
@ -48,6 +49,9 @@ pub extern "C" fn fog_init(
app_id_override,
upload_enabled || recording_enabled,
uploader,
// Flipping it around, because no value = defaults to false,
// so we take in `disable` but pass on `enable`.
!disable_internal_pings,
)
.into()
}
@ -64,6 +68,7 @@ pub extern "C" fn fog_init(
pub extern "C" fn fog_init(
data_path_override: &nsACString,
app_id_override: &nsACString,
disable_internal_pings: bool,
) -> nsresult {
// On Android always enable Glean upload.
let upload_enabled = true;
@ -75,6 +80,7 @@ pub extern "C" fn fog_init(
app_id_override,
upload_enabled,
uploader,
!disable_internal_pings,
)
.into()
}
@ -84,6 +90,7 @@ fn fog_init_internal(
app_id_override: &nsACString,
upload_enabled: bool,
uploader: Option<Box<dyn glean::net::PingUploader>>,
enable_internal_pings: bool,
) -> Result<(), nsresult> {
metrics::fog::initialization.start();
@ -95,6 +102,7 @@ fn fog_init_internal(
conf.upload_enabled = upload_enabled;
conf.uploader = uploader;
conf.enable_internal_pings = enable_internal_pings;
// If we're operating in automation without any specific source tags to set,
// set the tag "automation" so any pings that escape don't clutter the tables.

Просмотреть файл

@ -95,7 +95,7 @@ already_AddRefed<FOG> FOG::GetSingleton() {
glean::fog::inits_during_shutdown.Add(1);
// It's enough to call init before shutting down.
// We don't need to (and can't) wait for it to complete.
glean::impl::fog_init(&VoidCString(), &VoidCString());
glean::impl::fog_init(&VoidCString(), &VoidCString(), false);
}
gFOG->Shutdown();
gFOG = nullptr;
@ -128,7 +128,8 @@ extern "C" bool FOG_IPCIsInAutomation(void) { return xpc::IsInAutomation(); }
NS_IMETHODIMP
FOG::InitializeFOG(const nsACString& aDataPathOverride,
const nsACString& aAppIdOverride) {
const nsACString& aAppIdOverride,
const bool aDisableInternalPings) {
MOZ_ASSERT(XRE_IsParentProcess());
gInitializeCalled = true;
RunOnShutdown(
@ -140,7 +141,8 @@ FOG::InitializeFOG(const nsACString& aDataPathOverride,
},
ShutdownPhase::AppShutdownConfirmed);
return glean::impl::fog_init(&aDataPathOverride, &aAppIdOverride);
return glean::impl::fog_init(&aDataPathOverride, &aAppIdOverride,
aDisableInternalPings);
}
NS_IMETHODIMP

Просмотреть файл

@ -17,8 +17,10 @@ interface nsIFOG : nsISupports
* instead of the profile dir.
* @param aAppIdOverride - The application_id to use instead of
* "firefox.desktop".
* @param aDisableInternalPings - Whether to disable internal pings (baseline, events, metrics).
* Default: false.
*/
void initializeFOG([optional] in AUTF8String aDataPathOverride, [optional] in AUTF8String aAppIdOverride);
void initializeFOG([optional] in AUTF8String aDataPathOverride, [optional] in AUTF8String aAppIdOverride, [optional] in boolean aDisableInternalPings);
/**
* Register custom pings.