mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
Bug 668312 - Report only probes defined in TelemetryHistograms.h r=Mossop
This commit is contained in:
parent
2ee0c861e5
commit
b0438e96a1
@ -121,13 +121,13 @@ HistogramGet(const char *name, PRUint32 min, PRUint32 max, PRUint32 bucketCount,
|
||||
|
||||
switch (histogramType) {
|
||||
case nsITelemetry::HISTOGRAM_EXPONENTIAL:
|
||||
*result = Histogram::FactoryGet(name, min, max, bucketCount, Histogram::kNoFlags);
|
||||
*result = Histogram::FactoryGet(name, min, max, bucketCount, Histogram::kUmaTargetedHistogramFlag);
|
||||
break;
|
||||
case nsITelemetry::HISTOGRAM_LINEAR:
|
||||
*result = LinearHistogram::FactoryGet(name, min, max, bucketCount, Histogram::kNoFlags);
|
||||
*result = LinearHistogram::FactoryGet(name, min, max, bucketCount, Histogram::kUmaTargetedHistogramFlag);
|
||||
break;
|
||||
case nsITelemetry::HISTOGRAM_BOOLEAN:
|
||||
*result = BooleanHistogram::FactoryGet(name, Histogram::kNoFlags);
|
||||
*result = BooleanHistogram::FactoryGet(name, Histogram::kUmaTargetedHistogramFlag);
|
||||
break;
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -172,6 +172,7 @@ ReflectHistogramSnapshot(JSContext *cx, JSObject *obj, Histogram *h)
|
||||
h->SnapshotSample(&ss);
|
||||
JSObject *counts_array;
|
||||
JSObject *rarray;
|
||||
jsval static_histogram = h->flags() && Histogram::kUmaTargetedHistogramFlag ? JSVAL_TRUE : JSVAL_FALSE;
|
||||
const size_t count = h->bucket_count();
|
||||
if (!(JS_DefineProperty(cx, obj, "min", INT_TO_JSVAL(h->declared_min()), NULL, NULL, JSPROP_ENUMERATE)
|
||||
&& JS_DefineProperty(cx, obj, "max", INT_TO_JSVAL(h->declared_max()), NULL, NULL, JSPROP_ENUMERATE)
|
||||
@ -182,6 +183,7 @@ ReflectHistogramSnapshot(JSContext *cx, JSObject *obj, Histogram *h)
|
||||
&& FillRanges(cx, rarray, h)
|
||||
&& (counts_array = JS_NewArrayObject(cx, count, NULL))
|
||||
&& JS_DefineProperty(cx, obj, "counts", OBJECT_TO_JSVAL(counts_array), NULL, NULL, JSPROP_ENUMERATE)
|
||||
&& JS_DefineProperty(cx, obj, "static", static_histogram, NULL, NULL, JSPROP_ENUMERATE)
|
||||
)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
@ -273,6 +275,7 @@ TelemetryImpl::NewHistogram(const nsACString &name, PRUint32 min, PRUint32 max,
|
||||
nsresult rv = HistogramGet(PromiseFlatCString(name).get(), min, max, bucketCount, histogramType, &h);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
h->ClearFlags(Histogram::kUmaTargetedHistogramFlag);
|
||||
return WrapAndReturnHistogram(h, cx, ret);
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,9 @@ function getHistograms() {
|
||||
|
||||
for (let key in hls) {
|
||||
let hgram = hls[key];
|
||||
if (!hgram.static)
|
||||
continue;
|
||||
|
||||
let r = hgram.ranges;
|
||||
let c = hgram.counts;
|
||||
let retgram = {
|
||||
@ -185,6 +188,7 @@ function TelemetryPing() {}
|
||||
|
||||
TelemetryPing.prototype = {
|
||||
_histograms: {},
|
||||
_initialized: false,
|
||||
_prevValues: {},
|
||||
|
||||
/**
|
||||
|
@ -61,6 +61,7 @@ interface nsITelemetry : nsISupports
|
||||
* counts - array representing contents of the buckets in the histogram
|
||||
* ranges - an array with calculated bucket sizes
|
||||
* sum - sum of the bucket contents
|
||||
* static - true for histograms defined in TelemetryHistograms.h, false for ones defined with newHistogram
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval histogramSnapshots;
|
||||
|
@ -13,6 +13,7 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const PATH = "/submit/telemetry/test-ping";
|
||||
const SERVER = "http://localhost:4444";
|
||||
const IGNORE_HISTOGRAM = "test::ignore_me";
|
||||
|
||||
const BinaryInputStream = Components.Constructor(
|
||||
"@mozilla.org/binaryinputstream;1",
|
||||
@ -22,8 +23,8 @@ const BinaryInputStream = Components.Constructor(
|
||||
var httpserver = new nsHttpServer();
|
||||
|
||||
function telemetry_ping () {
|
||||
let tp = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver);
|
||||
tp.observe(tp, "test-ping", SERVER);
|
||||
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver);
|
||||
TelemetryPing.observe(null, "test-ping", SERVER);
|
||||
}
|
||||
|
||||
function nonexistentServerObserver(aSubject, aTopic, aData) {
|
||||
@ -40,6 +41,8 @@ function nonexistentServerObserver(aSubject, aTopic, aData) {
|
||||
function telemetryObserver(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(telemetryObserver, aTopic);
|
||||
httpserver.registerPathHandler(PATH, checkHistograms);
|
||||
const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
|
||||
Telemetry.newHistogram(IGNORE_HISTOGRAM, 1, 2, 3, Telemetry.HISTOGRAM_BOOLEAN);
|
||||
telemetry_ping();
|
||||
}
|
||||
|
||||
@ -85,7 +88,8 @@ function checkHistograms(request, response) {
|
||||
|
||||
const TELEMETRY_PING = "TELEMETRY_PING";
|
||||
const TELEMETRY_SUCCESS = "TELEMETRY_SUCCESS";
|
||||
do_check_true(TELEMETRY_PING in payload.histograms)
|
||||
do_check_true(TELEMETRY_PING in payload.histograms);
|
||||
do_check_false(IGNORE_HISTOGRAM in payload.histograms);
|
||||
|
||||
// There should be one successful report from the previous telemetry ping.
|
||||
const expected_tc = {
|
||||
|
@ -32,6 +32,8 @@ function test_histogram(histogram_type, name, min, max, bucket_count) {
|
||||
do_check_eq(gh.min, min)
|
||||
do_check_eq(gh.max, max)
|
||||
|
||||
do_check_false(gh.static);
|
||||
|
||||
// Check that booleans work with nonboolean histograms
|
||||
h.add(false);
|
||||
h.add(true);
|
||||
@ -85,6 +87,7 @@ function test_getHistogramById() {
|
||||
do_check_eq(s.histogram_type, Telemetry.HISTOGRAM_EXPONENTIAL);
|
||||
do_check_eq(s.min, 1);
|
||||
do_check_eq(s.max, 10000);
|
||||
do_check_true(s.static);
|
||||
}
|
||||
|
||||
// Check that telemetry doesn't record in private mode
|
||||
|
Loading…
Reference in New Issue
Block a user