зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1539262 - Record if Origin Telemetry was used with an unknown origin. r=janerik
Differential Revision: https://phabricator.services.mozilla.com/D25130 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2339f1df9b
Коммит
19a6e337c5
|
@ -135,8 +135,10 @@ static uint32_t gPrioDataCount = 0;
|
|||
static uint32_t gPrioDatasPerMetric;
|
||||
|
||||
// The number of "meta-origins": in-band metadata about origin telemetry.
|
||||
// Currently 0. One is planned: the "unknown origin recorded" meta-origin.
|
||||
static uint32_t kNumMetaOrigins = 0;
|
||||
// Currently 1: the "unknown origin recorded" meta-origin.
|
||||
static uint32_t kNumMetaOrigins = 1;
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(kUnknownOrigin, "__UNKNOWN__");
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -222,9 +224,14 @@ void TelemetryOrigin::InitializeGlobalState() {
|
|||
|
||||
gOriginToIndexMap = new OriginToIndexMap(gOriginsList->Length());
|
||||
for (size_t i = 0; i < gOriginsList->Length(); ++i) {
|
||||
MOZ_ASSERT(!kUnknownOrigin.Equals((*gOriginsList)[i]),
|
||||
"Unknown origin literal is reserved in Origin Telemetry");
|
||||
gOriginToIndexMap->Put(nsDependentCString((*gOriginsList)[i]), i);
|
||||
}
|
||||
|
||||
// Add the meta-origin for tracking recordings to untracked origins.
|
||||
gOriginToIndexMap->Put(kUnknownOrigin, gOriginsList->Length());
|
||||
|
||||
gMetricToOriginsMap = new IdToOriginsMap();
|
||||
|
||||
// This map shouldn't change at runtime, so make debug builds complain
|
||||
|
@ -274,9 +281,16 @@ nsresult TelemetryOrigin::RecordOrigin(OriginMetricID aId,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCString origin(aOrigin);
|
||||
if (!gOriginToIndexMap->Contains(aOrigin)) {
|
||||
// Only record one unknown origin per metric per snapshot.
|
||||
// (otherwise we may get swamped and blow our data budget.)
|
||||
if (gMetricToOriginsMap->Contains(aId) &&
|
||||
gMetricToOriginsMap->GetOrInsert(aId).Contains(kUnknownOrigin)) {
|
||||
return NS_OK;
|
||||
}
|
||||
origin = kUnknownOrigin;
|
||||
}
|
||||
|
||||
if (!gMetricToOriginsMap->Contains(aId)) {
|
||||
// If we haven't recorded anything for this metric yet, we're adding some
|
||||
|
@ -286,13 +300,13 @@ nsresult TelemetryOrigin::RecordOrigin(OriginMetricID aId,
|
|||
|
||||
auto& originArray = gMetricToOriginsMap->GetOrInsert(aId);
|
||||
|
||||
if (originArray.Contains(aOrigin)) {
|
||||
if (originArray.Contains(origin)) {
|
||||
// If we've already recorded this metric for this origin, then we're going
|
||||
// to need more prioDatas to encode that it happened again.
|
||||
gPrioDataCount += gPrioDatasPerMetric;
|
||||
}
|
||||
|
||||
originArray.AppendElement(aOrigin);
|
||||
originArray.AppendElement(origin);
|
||||
|
||||
static uint32_t sPrioPingLimit =
|
||||
mozilla::Preferences::GetUint("toolkit.telemetry.prioping.dataLimit", 10);
|
||||
|
|
Загрузка…
Ссылка в новой задаче