bug 1440673 - Set the max number of event summary keys by pref r?Dexter
Introducing the pref toolkit.telemetry.maxEventSummaryKeys which we should
hopefully never have to think about because (and yes, I risk being quoted in
future for this):
500 unique event names per process ought to be enough.
We check the preference just once but have to set it each time as the
KeyedScalar object may have been recreated while we weren't looking.
MozReview-Commit-ID: 8IE9dcfuynh
--- a/toolkit/components/telemetry/TelemetryScalar.cpp
+++ b/toolkit/components/telemetry/TelemetryScalar.cpp
@@ -13,26 +13,28 @@
#include "nsDataHashtable.h"
#include "nsIXPConnect.h"
#include "nsContentUtils.h"
#include "nsThreadUtils.h"
#include "nsJSUtils.h"
#include "nsPrintfCString.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/PContent.h"
+#include "mozilla/Preferences.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Unused.h"
#include "TelemetryCommon.h"
#include "TelemetryScalar.h"
#include "TelemetryScalarData.h"
#include "ipc/TelemetryComms.h"
#include "ipc/TelemetryIPCAccumulator.h"
+using mozilla::Preferences;
using mozilla::StaticAutoPtr;
using mozilla::StaticMutex;
using mozilla::StaticMutexAutoLock;
using mozilla::Telemetry::Common::AutoHashtable;
using mozilla::Telemetry::Common::IsExpiredVersion;
using mozilla::Telemetry::Common::CanRecordDataset;
using mozilla::Telemetry::Common::IsInDataset;
using mozilla::Telemetry::Common::LogToBrowserConsole;
@@ -2548,16 +2550,22 @@ TelemetryScalar::SummarizeEvent(const ns
KeyedScalar* scalar = nullptr;
nsresult rv = internal_GetKeyedScalarByEnum(lock, scalarKey, aProcessType, &scalar);
if (NS_FAILED(rv)) {
NS_WARNING("NS_FAILED getting keyed scalar telemetry.event_counts. Wut.");
return;
}
+ static uint32_t sMaxEventSummaryKeys =
+ Preferences::GetUint("toolkit.telemetry.maxEventSummaryKeys", 500);
+
+ // Set this each time as it may have been cleared and recreated between calls
+ scalar->SetMaximumNumberOfKeys(sMaxEventSummaryKeys);
+
scalar->AddValue(NS_ConvertASCIItoUTF16(aUniqueEventName), 1);
}
/**
* Resets all the stored scalars. This is intended to be only used in tests.
*/
void
TelemetryScalar::ClearScalars()