зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1356223 - Support scalar telemetry probe types in Telemetry.js r=pbro
MozReview-Commit-ID: A2SMdvjy4jp --HG-- extra : rebase_source : 002e47280d926c913150dd1b1286a7730855a024
This commit is contained in:
Родитель
7ebdf5f8b2
Коммит
faf7c1b49c
|
@ -79,7 +79,6 @@ function loadTelemetryAndRecordLogs() {
|
|||
info("Mock the Telemetry log function to record logged information");
|
||||
|
||||
let Telemetry = require("devtools/client/shared/telemetry");
|
||||
|
||||
Telemetry.prototype.telemetryInfo = {};
|
||||
Telemetry.prototype._oldlog = Telemetry.prototype.log;
|
||||
Telemetry.prototype.log = function (histogramId, value) {
|
||||
|
@ -94,6 +93,8 @@ function loadTelemetryAndRecordLogs() {
|
|||
this.telemetryInfo[histogramId].push(value);
|
||||
}
|
||||
};
|
||||
Telemetry.prototype._oldlogScalar = Telemetry.prototype.logScalar;
|
||||
Telemetry.prototype.logScalar = Telemetry.prototype.log;
|
||||
Telemetry.prototype._oldlogKeyed = Telemetry.prototype.logKeyed;
|
||||
Telemetry.prototype.logKeyed = function (histogramId, key, value) {
|
||||
this.log(`${histogramId}|${key}`, value);
|
||||
|
@ -110,8 +111,10 @@ function loadTelemetryAndRecordLogs() {
|
|||
function stopRecordingTelemetryLogs(Telemetry) {
|
||||
info("Stopping Telemetry");
|
||||
Telemetry.prototype.log = Telemetry.prototype._oldlog;
|
||||
Telemetry.prototype.logScalar = Telemetry.prototype._oldlogScalar;
|
||||
Telemetry.prototype.logKeyed = Telemetry.prototype._oldlogKeyed;
|
||||
delete Telemetry.prototype._oldlog;
|
||||
delete Telemetry.prototype._oldlogScalar;
|
||||
delete Telemetry.prototype._oldlogKeyed;
|
||||
delete Telemetry.prototype.telemetryInfo;
|
||||
}
|
||||
|
|
|
@ -584,6 +584,8 @@ function loadTelemetryAndRecordLogs() {
|
|||
this.telemetryInfo[histogramId].push(value);
|
||||
}
|
||||
};
|
||||
Telemetry.prototype._oldlogScalar = Telemetry.prototype.logScalar;
|
||||
Telemetry.prototype.logScalar = Telemetry.prototype.log;
|
||||
Telemetry.prototype._oldlogKeyed = Telemetry.prototype.logKeyed;
|
||||
Telemetry.prototype.logKeyed = function (histogramId, key, value) {
|
||||
this.log(`${histogramId}|${key}`, value);
|
||||
|
@ -600,8 +602,10 @@ function loadTelemetryAndRecordLogs() {
|
|||
function stopRecordingTelemetryLogs(Telemetry) {
|
||||
info("Stopping Telemetry");
|
||||
Telemetry.prototype.log = Telemetry.prototype._oldlog;
|
||||
Telemetry.prototype.logScalar = Telemetry.prototype._oldlogScalar;
|
||||
Telemetry.prototype.logKeyed = Telemetry.prototype._oldlogKeyed;
|
||||
delete Telemetry.prototype._oldlog;
|
||||
delete Telemetry.prototype._oldlogScalar;
|
||||
delete Telemetry.prototype._oldlogKeyed;
|
||||
delete Telemetry.prototype.telemetryInfo;
|
||||
}
|
||||
|
|
|
@ -199,6 +199,9 @@ Telemetry.prototype = {
|
|||
if (charts.timerHistogram) {
|
||||
this.startTimer(charts.timerHistogram);
|
||||
}
|
||||
if (charts.scalar) {
|
||||
this.logScalar(charts.scalar, 1);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -260,14 +263,44 @@ Telemetry.prototype = {
|
|||
* Value to store.
|
||||
*/
|
||||
log: function (histogramId, value) {
|
||||
if (histogramId) {
|
||||
try {
|
||||
let histogram = Services.telemetry.getHistogramById(histogramId);
|
||||
histogram.add(value);
|
||||
} catch (e) {
|
||||
dump("Warning: An attempt was made to write to the " + histogramId +
|
||||
" histogram, which is not defined in Histograms.json\n");
|
||||
if (!histogramId) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
let histogram = Services.telemetry.getHistogramById(histogramId);
|
||||
histogram.add(value);
|
||||
} catch (e) {
|
||||
dump(`Warning: An attempt was made to write to the ${histogramId} ` +
|
||||
`histogram, which is not defined in Histograms.json\n`);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Log a value to a scalar.
|
||||
*
|
||||
* @param {String} scalarId
|
||||
* Scalar in which the data is to be stored.
|
||||
* @param value
|
||||
* Value to store.
|
||||
*/
|
||||
logScalar: function (scalarId, value) {
|
||||
if (!scalarId) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (isNaN(value)) {
|
||||
dump(`Warning: An attempt was made to write a non-numeric value ` +
|
||||
`${value} to the ${scalarId} scalar. Only numeric values are ` +
|
||||
`allowed.`);
|
||||
|
||||
return;
|
||||
}
|
||||
Services.telemetry.scalarSet(scalarId, value);
|
||||
} catch (e) {
|
||||
dump(`Warning: An attempt was made to write to the ${scalarId} ` +
|
||||
`scalar, which is not defined in Scalars.yaml\n`);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -292,8 +325,8 @@ Telemetry.prototype = {
|
|||
histogram.add(key, value);
|
||||
}
|
||||
} catch (e) {
|
||||
dump("Warning: An attempt was made to write to the " + histogramId +
|
||||
" histogram, which is not defined in Histograms.json\n");
|
||||
dump(`Warning: An attempt was made to write to the ${histogramId} ` +
|
||||
`histogram, which is not defined in Histograms.json\n`);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче