Bug 1920562 - Remove C++ Telemetry::SetEventRecordingEnabled r=florian,necko-reviewers,valentin

We leave the network.trr.confirmation_telemetry_enabled pref intact because
removing it causes failures in test_prefs_tracker.js

Differential Revision: https://phabricator.services.mozilla.com/D223832
This commit is contained in:
Chris H-C 2024-10-08 20:14:41 +00:00
parent 84aa2d26d5
commit d5675e4d9d
16 changed files with 1 additions and 126 deletions

View file

@ -166,7 +166,6 @@
#include "mozilla/net/CookieKey.h"
#include "mozilla/net/TRRService.h"
#include "mozilla/TelemetryComms.h"
#include "mozilla/TelemetryEventEnums.h"
#include "mozilla/RemoteLazyInputStreamParent.h"
#include "mozilla/widget/RemoteLookAndFeel.h"
#include "mozilla/widget/ScreenManager.h"
@ -1204,17 +1203,9 @@ IPCResult ContentParent::RecvAttributionConversion(
return IPC_OK();
}
Atomic<bool, mozilla::Relaxed> sContentParentTelemetryEventEnabled(false);
/*static*/
void ContentParent::LogAndAssertFailedPrincipalValidationInfo(
nsIPrincipal* aPrincipal, const char* aMethod) {
// nsContentSecurityManager may also enable this same event, but that's okay
if (!sContentParentTelemetryEventEnabled.exchange(true)) {
sContentParentTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("security"_ns, true);
}
// Send Telemetry
nsAutoCString principalScheme, principalType, spec;
mozilla::glean::security::FissionPrincipalsExtra extra = {};

View file

@ -1510,8 +1510,6 @@ QuotaManager::Observer::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
Telemetry::SetEventRecordingEnabled("dom.quota.try"_ns, true);
gBasePath = new nsString();
nsCOMPtr<nsIFile> baseDir;
@ -1598,8 +1596,6 @@ QuotaManager::Observer::Observe(nsISupports* aSubject, const char* aTopic,
gBuildId = nullptr;
Telemetry::SetEventRecordingEnabled("dom.quota.try"_ns, false);
return NS_OK;
}

View file

@ -48,7 +48,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_security.h"
#include "mozilla/Telemetry.h"
#include "xpcpublic.h"
#include "nsMimeTypes.h"
@ -57,7 +56,6 @@
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::Telemetry;
NS_IMPL_ISUPPORTS(nsContentSecurityManager, nsIContentSecurityManager,
nsIChannelEventSink)
@ -71,7 +69,6 @@ Atomic<bool, mozilla::Relaxed> sJSHacksChecked(false);
Atomic<bool, mozilla::Relaxed> sJSHacksPresent(false);
Atomic<bool, mozilla::Relaxed> sCSSHacksChecked(false);
Atomic<bool, mozilla::Relaxed> sCSSHacksPresent(false);
Atomic<bool, mozilla::Relaxed> sTelemetryEventEnabled(false);
/* static */
bool nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
@ -838,11 +835,6 @@ void nsContentSecurityManager::MeasureUnexpectedPrivilegedLoads(
MOZ_LOG(sCSMLog, LogLevel::Debug,
("- redirects: %s\n\n", loggedRedirects.get()));
// Send Telemetry
if (!sTelemetryEventEnabled.exchange(true)) {
Telemetry::SetEventRecordingEnabled("security"_ns, true);
}
glean::security::UnexpectedLoadExtra extra = {
.contenttype = Some(loggedContentType),
.filedetails = Some(loggedFileDetails),

View file

@ -45,20 +45,17 @@
#include "LoadInfo.h"
#include "mozilla/StaticPrefs_extensions.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/Telemetry.h"
#include "nsIConsoleService.h"
#include "nsIStringBundle.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::Telemetry;
extern mozilla::LazyLogModule sCSMLog;
extern Atomic<bool, mozilla::Relaxed> sJSHacksChecked;
extern Atomic<bool, mozilla::Relaxed> sJSHacksPresent;
extern Atomic<bool, mozilla::Relaxed> sCSSHacksChecked;
extern Atomic<bool, mozilla::Relaxed> sCSSHacksPresent;
extern Atomic<bool, mozilla::Relaxed> sTelemetryEventEnabled;
// Helper function for IsConsideredSameOriginForUIR which makes
// Principals of scheme 'http' return Principals of scheme 'https'.
@ -744,10 +741,6 @@ void nsContentSecurityUtils::NotifyEvalUsage(bool aIsSystemPrincipal,
uint32_t aColumnNumber) {
FilenameTypeAndDetails fileNameTypeAndDetails =
FilenameToFilenameType(aFileName, false);
if (!sTelemetryEventEnabled.exchange(true)) {
sTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("security"_ns, true);
}
auto fileinfo = fileNameTypeAndDetails.second;
auto value = Some(fileNameTypeAndDetails.first);
if (aIsSystemPrincipal) {
@ -1574,10 +1567,6 @@ bool nsContentSecurityUtils::ValidateScriptFilename(JSContext* cx,
FilenameTypeAndDetails fileNameTypeAndDetails =
FilenameToFilenameType(filename, true);
if (!sTelemetryEventEnabled.exchange(true)) {
sTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("security"_ns, true);
}
glean::security::JavascriptLoadParentProcessExtra extra = {
.fileinfo = fileNameTypeAndDetails.second,
.value = Some(fileNameTypeAndDetails.first),

View file

@ -110,10 +110,6 @@ bool UtilityProcessHost::Launch(geckoargs::ChildProcessArgs aExtraOpts) {
EnsureWidevineL1PathForSandbox(aExtraOpts);
#endif
#if defined(MOZ_WMF_CDM) && defined(MOZ_SANDBOX)
EnanbleMFCDMTelemetryEventIfNeeded();
#endif
mLaunchPhase = LaunchPhase::Waiting;
if (!GeckoChildProcessHost::AsyncLaunch(std::move(aExtraOpts))) {
@ -414,17 +410,4 @@ void UtilityProcessHost::EnsureWidevineL1PathForSandbox(
#endif
#if defined(MOZ_WMF_CDM) && defined(MOZ_SANDBOX)
void UtilityProcessHost::EnanbleMFCDMTelemetryEventIfNeeded() const {
if (mSandbox != SandboxingKind::MF_MEDIA_ENGINE_CDM) {
return;
}
static bool sTelemetryEventEnabled = false;
if (!sTelemetryEventEnabled) {
sTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("mfcdm"_ns, true);
}
}
#endif
} // namespace mozilla::ipc

View file

@ -586,7 +586,6 @@ AutoScriptActivity::~AutoScriptActivity() {
}
static const double sChromeSlowScriptTelemetryCutoff(10.0);
static bool sTelemetryEventEnabled(false);
// static
bool XPCJSContext::InterruptCallback(JSContext* cx) {
@ -1444,11 +1443,6 @@ void XPCJSContext::AfterProcessTask(uint32_t aNewRecursionDepth) {
}
}
if (hangDuration > limit) {
if (!sTelemetryEventEnabled) {
sTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("slow_script_warning"_ns, true);
}
// Use AppendFloat to avoid printf-type APIs using locale-specific
// decimal separators, when we definitely want a `.`.
nsCString durationStr;

View file

@ -24,7 +24,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/GleanMetrics.h"
#include "private/pprio.h"
#include "nsInputStreamPump.h"
@ -871,7 +870,6 @@ static void RecordZeroLengthEvent(bool aIsSync, const nsCString& aSpec,
bool isTest = fileName.Find("test_empty_file.zip!") != -1;
bool isOmniJa = StringBeginsWith(fileName, "omni.ja!"_ns);
Telemetry::SetEventRecordingEnabled("zero_byte_load"_ns, true);
if (StringEndsWith(fileName, ".ftl"_ns)) {
// FTL uses I/O to test for file presence, so we get
// a high volume of events from it, but it is not erronous.

View file

@ -161,8 +161,6 @@ static void ShutdownAlwaysPrefs();
// Low-level types and operations
//===========================================================================
Atomic<bool, mozilla::Relaxed> sPrefTelemetryEventEnabled(false);
typedef nsTArray<nsCString> PrefSaveData;
// 1 MB should be enough for everyone.
@ -663,10 +661,6 @@ class Pref {
#define CHECK_SANITIZATION() \
if (IsPreferenceSanitized(this)) { \
if (!sPrefTelemetryEventEnabled.exchange(true)) { \
sPrefTelemetryEventEnabled = true; \
Telemetry::SetEventRecordingEnabled("security"_ns, true); \
} \
glean::security::pref_usage_content_process.Record( \
Some(glean::security::PrefUsageContentProcessExtra{Some(Name())})); \
if (sCrashOnBlocklistedPref) { \
@ -1176,11 +1170,6 @@ class MOZ_STACK_CLASS PrefWrapper : public PrefWrapperBase {
// This check will be performed in the above functions; but for NoneType
// we need to do it explicitly, then fall-through.
if (IsPreferenceSanitized(Name())) {
if (!sPrefTelemetryEventEnabled.exchange(true)) {
sPrefTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("security"_ns, true);
}
glean::security::pref_usage_content_process.Record(Some(
glean::security::PrefUsageContentProcessExtra{Some(Name())}));
@ -1203,11 +1192,6 @@ class MOZ_STACK_CLASS PrefWrapper : public PrefWrapperBase {
// WantValueKind may short-circuit GetValue functions and cause them to
// return early, before this check occurs in GetFooValue()
if (this->is<Pref*>() && IsPreferenceSanitized(this->as<Pref*>())) {
if (!sPrefTelemetryEventEnabled.exchange(true)) {
sPrefTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("security"_ns, true);
}
glean::security::pref_usage_content_process.Record(
Some(glean::security::PrefUsageContentProcessExtra{Some(Name())}));
@ -5417,11 +5401,6 @@ int32_t Preferences::GetType(const char* aPrefName) {
case PrefType::None:
if (IsPreferenceSanitized(aPrefName)) {
if (!sPrefTelemetryEventEnabled.exchange(true)) {
sPrefTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("security"_ns, true);
}
glean::security::pref_usage_content_process.Record(Some(
glean::security::PrefUsageContentProcessExtra{Some(aPrefName)}));

View file

@ -164,12 +164,6 @@ bool TRRService::CheckCaptivePortalIsPassed() {
return result;
}
static void EventTelemetryPrefChanged(const char* aPref, void* aData) {
Telemetry::SetEventRecordingEnabled(
"network.dns"_ns,
StaticPrefs::network_trr_confirmation_telemetry_enabled());
}
nsresult TRRService::Init(bool aNativeHTTPSQueryEnabled) {
MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
if (mInitialized) {
@ -215,10 +209,6 @@ nsresult TRRService::Init(bool aNativeHTTPSQueryEnabled) {
sTRRBackgroundThread = thread;
}
Preferences::RegisterCallbackAndCall(
EventTelemetryPrefChanged,
"network.trr.confirmation_telemetry_enabled"_ns);
LOG(("Initialized TRRService\n"));
return NS_OK;
}

View file

@ -34,7 +34,6 @@
#include "mozilla/BasePrincipal.h"
#include "mozilla/IntegerTypeTraits.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/GleanMetrics.h"
#include "nsThreadUtils.h"
@ -1108,7 +1107,6 @@ nsresult nsExpatDriver::HandleError() {
docShellDestroyed.Assign(destroyed ? "true"_ns : "false"_ns);
}
mozilla::Telemetry::SetEventRecordingEnabled("ysod"_ns, true);
mozilla::glean::ysod::ShownYsodExtra extra = {
.destroyed = mozilla::Some(docShellDestroyed),
.errorCode = mozilla::Some(code),

View file

@ -1126,14 +1126,6 @@ nsCookieBannerService::OnLocationChange(nsIWebProgress* aWebProgress,
return NS_OK;
}
// The static value to track if we have enabled the event telemetry for
// cookie banner.
static bool sTelemetryEventEnabled = false;
if (!sTelemetryEventEnabled) {
sTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("cookie_banner"_ns, true);
}
glean::cookie_banners::ReloadExtra extra = {
.hasClickRule = Some(hasClickRuleInData),
.hasCookieRule = Some(hasCookieRuleInData),

View file

@ -195,7 +195,6 @@ nsresult NimbusFeatures::RecordExposureEvent(const nsACString& aFeatureId,
// this featureId
return NS_ERROR_UNEXPECTED;
}
Telemetry::SetEventRecordingEnabled("normandy"_ns, true);
glean::normandy::expose_nimbus_experiment.Record(
Some(glean::normandy::ExposeNimbusExperimentExtra{
.branchslug = Some(branchName),

View file

@ -2012,10 +2012,6 @@ void ScalarSetMaximum(mozilla::Telemetry::ScalarID aId, const nsAString& aKey,
TelemetryScalar::SetMaximum(aId, aKey, aVal);
}
void SetEventRecordingEnabled(const nsACString& aCategory, bool aEnabled) {
TelemetryEvent::SetEventRecordingEnabled(aCategory, aEnabled);
}
void ShutdownTelemetry() { TelemetryImpl::ShutdownTelemetry(); }
} // namespace mozilla::Telemetry

View file

@ -549,16 +549,6 @@ class MOZ_RAII AutoScalarTimer {
const nsString key;
};
/**
* Enables recording of events in a category.
* Events default to recording enabled.
* This toggles recording for all events in the specified category.
*
* @param aCategory The category name.
* @param aEnabled Whether recording should be enabled or disabled.
*/
void SetEventRecordingEnabled(const nsACString& aCategory, bool aEnabled);
} // namespace Telemetry
} // namespace mozilla

View file

@ -40,17 +40,7 @@ TEST_F(TelemetryTestFixture, RecordEventNative) {
"this extra value is much too long and must be truncated to fit in the "
"limit which at time of writing was 80 bytes.");
// Ensure "telemetry.test" is disabled
Telemetry::SetEventRecordingEnabled(category, false);
// Try recording before category's enabled.
TelemetryEvent::RecordEventNative(
Telemetry::EventID::TelemetryTest_Test1_Object1, Nothing(), Nothing());
// Ensure "telemetry.test" is enabled
Telemetry::SetEventRecordingEnabled(category, true);
// Try recording after it's enabled.
// Try recording.
TelemetryEvent::RecordEventNative(
Telemetry::EventID::TelemetryTest_Test2_Object1, Nothing(), Nothing());

View file

@ -12,7 +12,6 @@
#include "mozilla/RefPtr.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/GleanMetrics.h"
#include "nsExceptionHandler.h"
#include "nsMemoryPressure.h"
@ -163,7 +162,6 @@ void nsAvailableMemoryWatcherBase::UpdateLowMemoryTimeStamp() {
void nsAvailableMemoryWatcherBase::RecordTelemetryEventOnHighMemory(
const MutexAutoLock&) {
Telemetry::SetEventRecordingEnabled("memory_watcher"_ns, true);
glean::memory_watcher::on_high_memory_stats.Record(
Some(glean::memory_watcher::OnHighMemoryStatsExtra{
Some(nsPrintfCString(