Bug 1345546 - Add telemetry for feed protocols pcast and feed. r=Gijs
authorJonathan Kingston <jkt@mozilla.com>
Wed, 08 Mar 2017 17:32:52 +0000
changeset 395509 bdffd6128546a6c22e74178fbcfce5f310b36198
parent 395508 f64fabc72583884c9753416b17af9823a5160265
child 395510 58feb843a9ae07d3f53b00668fc3b3d7ede9ea1d
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1345546
milestone55.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 1345546 - Add telemetry for feed protocols pcast and feed. r=Gijs MozReview-Commit-ID: FPw18txy6gE
browser/components/feeds/FeedConverter.js
toolkit/components/telemetry/Histograms.json
--- a/browser/components/feeds/FeedConverter.js
+++ b/browser/components/feeds/FeedConverter.js
@@ -498,43 +498,74 @@ GenericProtocolHandler.prototype = {
   get defaultPort() {
     return this._http.defaultPort;
   },
 
   allowPort(port, scheme) {
     return this._http.allowPort(port, scheme);
   },
 
+  _getTelemetrySchemeId() {
+    // Gets a scheme id from 1-8
+    let schemeId;
+    if (!this._telemetrySubScheme) {
+      schemeId = 1;
+    } else {
+      switch (this._telemetryInnerScheme) {
+        case "http":
+          schemeId = 2;
+          break;
+        case "https":
+          schemeId = 3;
+          break;
+        default:
+          // Invalid scheme
+          schemeId = 4;
+      }
+    }
+    if (this._scheme === "pcast") {
+      schemeId += 4;
+    }
+    return schemeId;
+  },
+
   newURI(spec, originalCharset, baseURI) {
     // Feed URIs can be either nested URIs of the form feed:realURI (in which
     // case we create a nested URI for the realURI) or feed://example.com, in
     // which case we create a nested URI for the real protocol which is http.
 
     let scheme = this._scheme + ":";
     if (spec.substr(0, scheme.length) != scheme)
       throw Cr.NS_ERROR_MALFORMED_URI;
 
+    this._telemetrySubScheme = spec.substr(scheme.length, 2) != "//";
+
     let prefix = spec.substr(scheme.length, 2) == "//" ? "http:" : "";
     let inner = Services.io.newURI(spec.replace(scheme, prefix),
                                    originalCharset, baseURI);
+    this._telemetryInnerScheme = inner.scheme;
+
 
     if (!["http", "https"].includes(inner.scheme))
       throw Cr.NS_ERROR_MALFORMED_URI;
 
     let uri = Services.io.QueryInterface(Ci.nsINetUtil).newSimpleNestedURI(inner);
     uri.spec = inner.spec.replace(prefix, scheme);
     return uri;
   },
 
   newChannel2(aUri, aLoadInfo) {
     let inner = aUri.QueryInterface(Ci.nsINestedURI).innerURI;
     let channel = Cc["@mozilla.org/network/io-service;1"].
                   getService(Ci.nsIIOService).
                   newChannelFromURIWithLoadInfo(inner, aLoadInfo);
 
+    const schemeId = this._getTelemetrySchemeId();
+    Services.telemetry.getHistogramById("FEED_PROTOCOL_USAGE").add(schemeId);
+
     if (channel instanceof Components.interfaces.nsIHttpChannel)
       // Set this so we know this is supposed to be a feed
       channel.setRequestHeader("X-Moz-Is-Feed", "1", false);
     channel.originalURI = aUri;
     return channel;
   },
 
   QueryInterface(iid) {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -750,16 +750,24 @@
   "FAMILY_SAFETY": {
     "alert_emails": ["seceng@mozilla.org"],
     "expires_in_version": "55",
     "kind": "enumerated",
     "n_values": 16,
     "bug_numbers": [1239166],
     "description": "Status of Family Safety detection and remediation. See nsNSSComponent.cpp."
   },
+  "FEED_PROTOCOL_USAGE": {
+    "alert_emails": ["jkt@mozilla.com"],
+    "bug_numbers": [1345546],
+    "expires_in_version": "60",
+    "kind": "enumerated",
+    "n_values": 8,
+    "description": "Usage counts of feed protocols used to load a page. (1=feed, 2=feed:http, 3=feed:https, 4=feed:brokenScheme, 5=pcast, 6=pcast:http, 7=pcast:https, 8=pcast:brokenScheme)"
+  },
   "FETCH_IS_MAINTHREAD": {
     "expires_in_version": "50",
     "kind": "boolean",
     "description": "Was Fetch request initiated from the main thread?"
   },
   "FORCED_DEVICE_RESET_REASON": {
     "expires_in_version": "never",
     "kind": "enumerated",