mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1802204 - Add feature for DAP telemetry - r=barret
Differential Revision: https://phabricator.services.mozilla.com/D162903
This commit is contained in:
parent
2951b29286
commit
ce9c3dd6cd
@ -2839,10 +2839,7 @@ BrowserGlue.prototype = {
|
||||
},
|
||||
|
||||
{
|
||||
condition: Services.prefs.getBoolPref(
|
||||
"toolkit.telemetry.dap_enabled",
|
||||
false
|
||||
),
|
||||
condition: lazy.NimbusFeatures.dapTelemetry.getVariable("enabled"),
|
||||
task: () => {
|
||||
lazy.DAPTelemetrySender.startup();
|
||||
},
|
||||
|
@ -674,6 +674,8 @@ pref("toolkit.telemetry.unified", true);
|
||||
|
||||
// DAP related preferences
|
||||
pref("toolkit.telemetry.dap_enabled", false);
|
||||
// Verification tasks
|
||||
pref("toolkit.telemetry.dap_task1_enabled", false);
|
||||
// Leader endpoint for the DAP protocol
|
||||
pref("toolkit.telemetry.dap_leader", "https://interop-00.api.divviup.org");
|
||||
// Not used for anything. Just additional information.
|
||||
|
@ -802,3 +802,18 @@ echPrefs:
|
||||
description: Probability of GREASEing a TLS connection with ECH (0-100).
|
||||
type: int
|
||||
setPref: "security.tls.ech.grease_probability"
|
||||
|
||||
dapTelemetry:
|
||||
description: DAP Telemetry
|
||||
owner: simon@mozilla.com
|
||||
hasExposure: false
|
||||
isEarlyStartup: true # Data is sent on startup with a trigger in BrowserGlue.jsm
|
||||
variables:
|
||||
enabled:
|
||||
type: boolean
|
||||
fallbackPref: toolkit.telemetry.dap_enabled
|
||||
description: Whether to automatically send DAP measurements.
|
||||
task1Enabled:
|
||||
type: boolean
|
||||
fallbackPref: toolkit.telemetry.dap_task1_enabled
|
||||
description: Whether to send fake measurements for verification task 1.
|
||||
|
@ -12,6 +12,9 @@ XPCOMUtils.defineLazyGetter(lazy, "logConsole", function() {
|
||||
maxLogLevelPref: "toolkit.telemetry.dap.logLevel",
|
||||
});
|
||||
});
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
|
||||
});
|
||||
|
||||
const PREF_LEADER = "toolkit.telemetry.dap_leader";
|
||||
const PREF_HELPER = "toolkit.telemetry.dap_helper";
|
||||
@ -29,14 +32,22 @@ XPCOMUtils.defineLazyPreferenceGetter(lazy, "HELPER", PREF_HELPER, undefined);
|
||||
|
||||
export const DAPTelemetrySender = new (class {
|
||||
startup() {
|
||||
this.sendVerificationTaskReport();
|
||||
lazy.logConsole.info("Performing DAP startup");
|
||||
|
||||
if (lazy.NimbusFeatures.dapTelemetry.getVariable("task1Enabled")) {
|
||||
// For now we are sending a constant value because it simplifies verification.
|
||||
let measurement = 3;
|
||||
this.sendVerificationTaskReport(measurement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For testing: sends a hard coded report for a hard coded task.
|
||||
*
|
||||
* @param {number} measurement
|
||||
*/
|
||||
async sendVerificationTaskReport() {
|
||||
lazy.logConsole.info("send_verification_task_report");
|
||||
async sendVerificationTaskReport(measurement) {
|
||||
lazy.logConsole.info("Trying to send verification task.");
|
||||
|
||||
// For now there is only a single task which is hardcoded here.
|
||||
/**
|
||||
@ -69,9 +80,6 @@ export const DAPTelemetrySender = new (class {
|
||||
return;
|
||||
}
|
||||
|
||||
// For now we are sending a constant value because it simplifies verification.
|
||||
let measurement = 3;
|
||||
|
||||
try {
|
||||
let report = await this.generateReport(task, measurement);
|
||||
Glean.dap.reportGenerationStatus.success.add(1);
|
||||
@ -152,9 +160,11 @@ export const DAPTelemetrySender = new (class {
|
||||
});
|
||||
|
||||
if (response.status != 200) {
|
||||
let error = await response.json();
|
||||
lazy.logConsole.error(
|
||||
`Sending failed with status: ${response.status} ${response.statusText}`
|
||||
`Sending failed. HTTP response: ${response.status} ${response.statusText}. Error: ${error.type} ${error.title}`
|
||||
);
|
||||
|
||||
Glean.dap.uploadStatus.failure.add(1);
|
||||
} else {
|
||||
lazy.logConsole.info("DAP report sent");
|
||||
|
Loading…
Reference in New Issue
Block a user