Bug 1416629: Add a telemetry to get how many precentage of synthesized cors response for same-origin mode request. r=bkelly, data-r=francois a=gchang
authorTom Tung <shes050117@gmail.com>
Thu, 16 Nov 2017 09:45:39 +0800
changeset 445057 b9d29c50dff5b02df9aa33af951baf0981eb485a
parent 445056 71956196206bba1b9fab23b31ce5201eb0c52d0d
child 445058 5405d1ebc3155fa2574d4a66452cd283358136ed
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly, gchang
bugs1416629
milestone58.0
Bug 1416629: Add a telemetry to get how many precentage of synthesized cors response for same-origin mode request. r=bkelly, data-r=francois a=gchang
dom/workers/ServiceWorkerEvents.cpp
toolkit/components/telemetry/Scalars.yaml
--- a/dom/workers/ServiceWorkerEvents.cpp
+++ b/dom/workers/ServiceWorkerEvents.cpp
@@ -664,16 +664,23 @@ RespondWithHandler::ResolvedCallback(JSC
   nsCString responseURL;
   if (response->Type() == ResponseType::Opaque) {
     responseURL = ir->GetUnfilteredURL();
     if (NS_WARN_IF(responseURL.IsEmpty())) {
       return;
     }
   }
 
+  Telemetry::ScalarAdd(Telemetry::ScalarID::SW_SYNTHESIZED_RES_COUNT, 1);
+
+  if (mRequestMode == RequestMode::Same_origin &&
+      response->Type() == ResponseType::Cors) {
+    Telemetry::ScalarAdd(Telemetry::ScalarID::SW_CORS_RES_FOR_SO_REQ_COUNT, 1);
+  }
+
   UniquePtr<RespondWithClosure> closure(new RespondWithClosure(mInterceptedChannel,
                                                                mRegistration,
                                                                mRequestURL,
                                                                mRespondWithScriptSpec,
                                                                mRespondWithLineNumber,
                                                                mRespondWithColumnNumber));
 
   nsCOMPtr<nsIRunnable> startRunnable = new StartResponse(mInterceptedChannel,
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -1325,16 +1325,49 @@ timestamps:
     expires: never
     kind: uint
     notification_emails:
       - hkirschner@mozilla.com
     release_channel_collection: opt-out
     record_in_processes:
       - main
 
+# The following section contains the service worker scalars.
+sw:
+  synthesized_res_count:
+    bug_numbers:
+      - 1416629
+    description: >
+      The count of number of synthesize response made by service workers.
+    expires: "61"
+    kind: uint
+    notification_emails:
+      - sw-telemetry@mozilla.com
+      - ttung@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+      - 'content'
+
+  cors_res_for_so_req_count:
+    bug_numbers:
+      - 1416629
+    description: >
+      The count of number of synthesize response made by service workers and
+      it's a cors type resposne for a same-origin mode request.
+    expires: "61"
+    kind: uint
+    notification_emails:
+      - sw-telemetry@mozilla.com
+      - ttung@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+      - 'content'
+
 # The following section is for probes testing the Telemetry system. They will not be
 # submitted in pings and are only used for testing.
 telemetry.test:
   unsigned_int_kind:
     bug_numbers:
       - 1276190
     description: >
       This is a test uint type with a really long description, maybe spanning even multiple