Bug 1398851 - Part 1: Add test logging for Telemetry PingServer requests. r=Dexter
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Tue, 12 Sep 2017 06:55:00 -0400
changeset 430172 b473e348c16dce58e340be28203d8e79f4562745
parent 430171 c0f7ab91792c957f05d47aacd25892f56dbaff10
child 430173 44cd91774b984608657cbec0ce81e784b755c32d
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDexter
bugs1398851
milestone57.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 1398851 - Part 1: Add test logging for Telemetry PingServer requests. r=Dexter
toolkit/components/telemetry/tests/unit/head.js
--- a/toolkit/components/telemetry/tests/unit/head.js
+++ b/toolkit/components/telemetry/tests/unit/head.js
@@ -13,16 +13,18 @@ Cu.import("resource://testing-common/htt
 Cu.import("resource://gre/modules/AppConstants.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "AddonTestUtils",
                                   "resource://testing-common/AddonTestUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetrySend",
                                   "resource://gre/modules/TelemetrySend.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Log",
+                                  "resource://gre/modules/Log.jsm");
 
 const gIsWindows = AppConstants.platform == "win";
 const gIsMac = AppConstants.platform == "macosx";
 const gIsAndroid = AppConstants.platform == "android";
 const gIsLinux = AppConstants.platform == "linux";
 
 const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
 
@@ -34,32 +36,43 @@ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f
 
 var gGlobalScope = this;
 
 const PingServer = {
   _httpServer: null,
   _started: false,
   _defers: [ PromiseUtils.defer() ],
   _currentDeferred: 0,
+  _logger: null,
 
   get port() {
     return this._httpServer.identity.primaryPort;
   },
 
   get started() {
     return this._started;
   },
 
+  get _log() {
+    if (!this._logger) {
+      this._logger = Log.repository.getLoggerWithMessagePrefix("Toolkit.Telemetry", "PingServer::");
+    }
+
+    return this._logger;
+  },
+
   registerPingHandler(handler) {
     const wrapped = wrapWithExceptionHandler(handler);
     this._httpServer.registerPrefixHandler("/submit/telemetry/", wrapped);
   },
 
   resetPingHandler() {
     this.registerPingHandler((request, response) => {
+      let r = request;
+      this._log.trace(`defaultPingHandler() - ${r.method} ${r.scheme}://${r.host}:${r.port}${r.path}`);
       let deferred = this._defers[this._defers.length - 1];
       this._defers.push(PromiseUtils.defer());
       deferred.resolve(request);
     });
   },
 
   start() {
     this._httpServer = new HttpServer();