Bug 1885204 - Use JS single sample accumulation for custom distributions where possible r=TravisLong,webidl,smaug
Differential Revision: https://phabricator.services.mozilla.com/D204549
This commit is contained in:
@@ -221,6 +221,16 @@ interface GleanCustomDistribution : GleanMetric {
|
||||
*/
|
||||
undefined accumulateSamples(sequence<long long> aSamples);
|
||||
|
||||
/**
|
||||
* Accumulates the provided single signed sample in the metric.
|
||||
*
|
||||
* @param aSample - The sample to be recorded by the metric.
|
||||
*
|
||||
* Notes: Discards any negative value of `sample` and reports an
|
||||
* `ErrorType::InvalidValue`.
|
||||
*/
|
||||
undefined accumulateSingleSample(long long aSample);
|
||||
|
||||
/**
|
||||
* **Test-only API**
|
||||
*
|
||||
|
||||
@@ -488,18 +488,18 @@ export class CookieBannerChild extends JSWindowActorChild {
|
||||
let querySelectorTimeUS = Math.round(querySelectorTimeMS * 1000);
|
||||
|
||||
if (this.#isTopLevel) {
|
||||
Glean.cookieBannersClick.querySelectorRunCountPerWindowTopLevel.accumulateSamples(
|
||||
[querySelectorCount]
|
||||
Glean.cookieBannersClick.querySelectorRunCountPerWindowTopLevel.accumulateSingleSample(
|
||||
querySelectorCount
|
||||
);
|
||||
Glean.cookieBannersClick.querySelectorRunDurationPerWindowTopLevel.accumulateSamples(
|
||||
[querySelectorTimeUS]
|
||||
Glean.cookieBannersClick.querySelectorRunDurationPerWindowTopLevel.accumulateSingleSample(
|
||||
querySelectorTimeUS
|
||||
);
|
||||
} else {
|
||||
Glean.cookieBannersClick.querySelectorRunCountPerWindowFrame.accumulateSamples(
|
||||
[querySelectorCount]
|
||||
Glean.cookieBannersClick.querySelectorRunCountPerWindowFrame.accumulateSingleSample(
|
||||
querySelectorCount
|
||||
);
|
||||
Glean.cookieBannersClick.querySelectorRunDurationPerWindowFrame.accumulateSamples(
|
||||
[querySelectorTimeUS]
|
||||
Glean.cookieBannersClick.querySelectorRunDurationPerWindowFrame.accumulateSingleSample(
|
||||
querySelectorTimeUS
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ class ExtensionTelemetryMetric {
|
||||
// NOTE: extensionsTiming may become a property of the GLEAN_METRICS_TYPES
|
||||
// map once we may introduce new histograms that are not part of the
|
||||
// extensionsTiming Glean metrics category.
|
||||
Glean.extensionsTiming[metric].accumulateSamples([value]);
|
||||
Glean.extensionsTiming[metric].accumulateSingleSample(value);
|
||||
break;
|
||||
}
|
||||
case "labeled_counter": {
|
||||
|
||||
@@ -97,6 +97,10 @@ void GleanCustomDistribution::AccumulateSamples(
|
||||
mCustomDist.AccumulateSamplesSigned(aSamples);
|
||||
}
|
||||
|
||||
void GleanCustomDistribution::AccumulateSingleSample(const int64_t aSample) {
|
||||
mCustomDist.AccumulateSingleSampleSigned(aSample);
|
||||
}
|
||||
|
||||
void GleanCustomDistribution::TestGetValue(
|
||||
const nsACString& aPingName,
|
||||
dom::Nullable<dom::GleanDistributionData>& aRetval, ErrorResult& aRv) {
|
||||
|
||||
@@ -95,6 +95,8 @@ class GleanCustomDistribution final : public GleanMetric {
|
||||
|
||||
void AccumulateSamples(const dom::Sequence<int64_t>& aSamples);
|
||||
|
||||
void AccumulateSingleSample(const int64_t aSample);
|
||||
|
||||
void TestGetValue(const nsACString& aPingName,
|
||||
dom::Nullable<dom::GleanDistributionData>& aRetval,
|
||||
ErrorResult& aRv);
|
||||
|
||||
@@ -47,7 +47,7 @@ export class PdfJsTelemetry {
|
||||
}
|
||||
|
||||
static onTimeToView(ms) {
|
||||
Glean.pdfjs.timeToView.accumulateSamples([ms]);
|
||||
Glean.pdfjs.timeToView.accumulateSingleSample(ms);
|
||||
}
|
||||
|
||||
static onEditing({ type, data }) {
|
||||
@@ -99,9 +99,9 @@ export class PdfJsTelemetry {
|
||||
Glean.pdfjsEditingHighlight.method[data.methodOfCreation].add(1);
|
||||
Glean.pdfjsEditingHighlight.color[data.color].add(1);
|
||||
if (data.type === "free_highlight") {
|
||||
Glean.pdfjsEditingHighlight.thickness.accumulateSamples([
|
||||
data.thickness,
|
||||
]);
|
||||
Glean.pdfjsEditingHighlight.thickness.accumulateSingleSample(
|
||||
data.thickness
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "color_changed":
|
||||
@@ -109,9 +109,9 @@ export class PdfJsTelemetry {
|
||||
Glean.pdfjsEditingHighlight.colorChanged.add(1);
|
||||
break;
|
||||
case "thickness_changed":
|
||||
Glean.pdfjsEditingHighlight.thickness.accumulateSamples([
|
||||
data.thickness,
|
||||
]);
|
||||
Glean.pdfjsEditingHighlight.thickness.accumulateSingleSample(
|
||||
data.thickness
|
||||
);
|
||||
Glean.pdfjsEditingHighlight.thicknessChanged.add(1);
|
||||
break;
|
||||
case "deleted":
|
||||
|
||||
@@ -64,7 +64,7 @@ export var BrowserTelemetryUtils = {
|
||||
} else if (currentTime >= this._lastRecordSiteOrigin + this.min_interval) {
|
||||
this._lastRecordSiteOrigin = currentTime;
|
||||
|
||||
Glean.geckoview.documentSiteOrigins.accumulateSamples([originCount]);
|
||||
Glean.geckoview.documentSiteOrigins.accumulateSingleSample(originCount);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user