Bug 1545365 - Track old and new send time to investigate negativ durations r=chutten
authorJan-Erik Rediger <jrediger@mozilla.com>
Fri, 26 Apr 2019 19:19:16 +0000
changeset 530454 c151677139852ef5443ec1c908f49f4cba07c7fc
parent 530441 58093e575a85553bb3b0c2b8d181c83529d4bb33
child 530455 bbd172d048d70b795867273c09ed7aec32c4d799
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1545365
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1545365 - Track old and new send time to investigate negativ durations r=chutten Differential Revision: https://phabricator.services.mozilla.com/D28847
toolkit/components/telemetry/Scalars.yaml
toolkit/components/telemetry/pings/EcosystemTelemetry.jsm
toolkit/components/telemetry/tests/unit/test_EcosystemTelemetry.js
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -2139,16 +2139,46 @@ telemetry:
     kind: uint
     notification_emails:
       - jrediger@mozilla.com
     release_channel_collection: opt-out
     record_in_processes:
       - 'main'
       - 'content'
 
+  ecosystem_old_send_time:
+    bug_numbers:
+      - 1545365
+    description: >
+      The timestamp im milliseconds of the last time we tried to send an Ecosystem ping
+    expires: "73"
+    kind: string
+    notification_emails:
+      - jrediger@mozilla.com
+    release_channel_collection: opt-in
+    record_in_processes:
+      - 'main'
+    record_into_store:
+      - 'pre-account'
+
+  ecosystem_new_send_time:
+    bug_numbers:
+      - 1545365
+    description: >
+      The timestamp im milliseconds of the last time we tried to send an Ecosystem ping
+    expires: "73"
+    kind: string
+    notification_emails:
+      - jrediger@mozilla.com
+    release_channel_collection: opt-in
+    record_in_processes:
+      - 'main'
+    record_into_store:
+      - 'pre-account'
+
 telemetry.discarded:
   accumulations:
     bug_numbers:
       - 1369041
     description: >
       Number of discarded accumulations to histograms in child processes
     expires: "never"
     kind: uint
--- a/toolkit/components/telemetry/pings/EcosystemTelemetry.jsm
+++ b/toolkit/components/telemetry/pings/EcosystemTelemetry.jsm
@@ -211,20 +211,31 @@ var EcosystemTelemetry = {
       // TODO(bug 1530654): Implement post-account ping
       this._log.trace(`Post-account ping not implemented yet. Sending pre-account instead.`);
       pingType = this.PingType.PRE;
     }
 
     this._log.trace(`_submitPing, ping type: ${pingType}, reason: ${reason}`);
 
     let now = Policy.monotonicNow();
+    let new_send_time = now;
+    let old_send_time = this._lastSendTime;
+
     // Duration in seconds
     let duration = Math.round((now - this._lastSendTime) / 1000);
     this._lastSendTime = now;
 
+    // FIXME(bug 1545365): This is a hack to track the values we see,
+    // in order to determine where negative durations are coming from.
+    // Note: These scalars must be set _before_ getting the rest of the payload.
+    // Note: We don't support signed integer scalars, so we convert these to strings
+    //       in order to also capture the negative values.
+    Services.telemetry.scalarSet("telemetry.ecosystem_old_send_time", old_send_time.toString());
+    Services.telemetry.scalarSet("telemetry.ecosystem_new_send_time", new_send_time.toString());
+
     let payload = this._payload(reason, duration);
 
     // Never include the client ID.
     // We provide our own environment.
     const options = {
       addClientId: false,
       addEnvironment: true,
       overrideEnvironment: this._environment(),
--- a/toolkit/components/telemetry/tests/unit/test_EcosystemTelemetry.js
+++ b/toolkit/components/telemetry/tests/unit/test_EcosystemTelemetry.js
@@ -46,16 +46,19 @@ function checkPingStructure(ping, type, 
   Assert.equal(payload.reason, reason, "Ping reason must match.");
   Assert.ok(payload.duration >= 0, "Payload must have a duration greater or equal to 0");
   Assert.ok("ecosystemClientId" in payload, "Payload must contain the ecosystem client ID");
 
   Assert.ok("scalars" in payload, "Payload must contain scalars");
   Assert.ok("keyedScalars" in payload, "Payload must contain keyed scalars");
   Assert.ok("histograms" in payload, "Payload must contain histograms");
   Assert.ok("keyedHistograms" in payload, "Payload must contain keyed histograms");
+
+  Assert.ok("telemetry.ecosystem_old_send_time" in payload.scalars.parent, "Old send time should be set");
+  Assert.ok("telemetry.ecosystem_new_send_time" in payload.scalars.parent, "New send time should be set");
 }
 
 function sendPing() {
   return TelemetryController.submitExternalPing(TEST_PING_TYPE, {}, {});
 }
 
 function fakeFxaUid(fn) {
   const m = ChromeUtils.import("resource://gre/modules/EcosystemTelemetry.jsm", null);