Bug 1404535: Add telemetry that times nr_ice_gather. r+drno r?rweiss draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 29 Sep 2017 17:49:32 -0500
changeset 674333 efd8bfabbb5d9b8724563482f704d761b7bc5658
parent 672686 935eca685536793ab7df8bfc9fb52d70128f7756
child 734294 af7090e6c67f9ef4e7b71b9dfa297dd79cdf3f3d
push id82796
push userbcampen@mozilla.com
push dateTue, 03 Oct 2017 16:08:36 +0000
reviewersrweiss
bugs1404535
milestone58.0a1
Bug 1404535: Add telemetry that times nr_ice_gather. r+drno r?rweiss MozReview-Commit-ID: I4nH8sZNX5g
media/mtransport/nricectx.cpp
toolkit/components/telemetry/Histograms.json
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -959,28 +959,37 @@ void NrIceCtx::SetCtxFlags(bool default_
 }
 
 nsresult NrIceCtx::StartGathering(bool default_route_only, bool proxy_only) {
   ASSERT_ON_THREAD(sts_target_);
   SetGatheringState(ICE_CTX_GATHER_STARTED);
 
   SetCtxFlags(default_route_only, proxy_only);
 
+  TimeStamp start = TimeStamp::Now();
   // This might start gathering for the first time, or again after
   // renegotiation, or might do nothing at all if gathering has already
   // finished.
   int r = nr_ice_gather(ctx_, &NrIceCtx::gather_cb, this);
 
+
   if (!r) {
     SetGatheringState(ICE_CTX_GATHER_COMPLETE);
+    Telemetry::AccumulateTimeDelta(
+        Telemetry::WEBRTC_ICE_NR_ICE_GATHER_TIME_IMMEDIATE_SUCCESS, start);
   } else if (r != R_WOULDBLOCK) {
     MOZ_MTLOG(ML_ERROR, "Couldn't gather ICE candidates for '"
                         << name_ << "', error=" << r);
     SetConnectionState(ICE_CTX_FAILED);
+    Telemetry::AccumulateTimeDelta(
+        Telemetry::WEBRTC_ICE_NR_ICE_GATHER_TIME_IMMEDIATE_FAILURE, start);
     return NS_ERROR_FAILURE;
+  } else {
+    Telemetry::AccumulateTimeDelta(
+        Telemetry::WEBRTC_ICE_NR_ICE_GATHER_TIME, start);
   }
 
   return NS_OK;
 }
 
 RefPtr<NrIceMediaStream> NrIceCtx::FindStream(
     nr_ice_media_stream *stream) {
   for (auto& stream_ : streams_) {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -8771,16 +8771,46 @@
     "alert_emails": ["webrtc-ice-telemetry-alerts@mozilla.com"],
     "bug_numbers": [1342523],
     "expires_in_version": "60",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 20,
     "description": "The length of time (in milliseconds) it took for the answerer to complete ICE, given that it failed. Does not count cases where StartChecks() was never called."
   },
+  "WEBRTC_ICE_NR_ICE_GATHER_TIME": {
+    "record_in_processes": ["content"],
+    "alert_emails": ["webrtc-ice-telemetry-alerts@mozilla.com", "bcampen@mozilla.com"],
+    "bug_numbers": [1319268],
+    "expires_in_version": "60",
+    "kind": "exponential",
+    "high": 10000,
+    "n_buckets": 20,
+    "description": "The length of time (in milliseconds) it took to call nr_ice_gather, given that gathering did not succeed/fail immediately during the call."
+  },
+  "WEBRTC_ICE_NR_ICE_GATHER_TIME_IMMEDIATE_FAILURE": {
+    "record_in_processes": ["content"],
+    "alert_emails": ["webrtc-ice-telemetry-alerts@mozilla.com", "bcampen@mozilla.com"],
+    "bug_numbers": [1319268],
+    "expires_in_version": "60",
+    "kind": "exponential",
+    "high": 10000,
+    "n_buckets": 20,
+    "description": "The length of time (in milliseconds) it took to call nr_ice_gather, given that gathering failed immediately during the call."
+  },
+  "WEBRTC_ICE_NR_ICE_GATHER_TIME_IMMEDIATE_SUCCESS": {
+    "record_in_processes": ["content"],
+    "alert_emails": ["webrtc-ice-telemetry-alerts@mozilla.com", "bcampen@mozilla.com"],
+    "bug_numbers": [1319268],
+    "expires_in_version": "60",
+    "kind": "exponential",
+    "high": 10000,
+    "n_buckets": 20,
+    "description": "The length of time (in milliseconds) it took to call nr_ice_gather, given that gathering succeeded immediately during the call."
+  },
   "WEBRTC_ICE_SUCCESS_TIME": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["webrtc-ice-telemetry-alerts@mozilla.com"],
     "bug_numbers": [1319268],
     "expires_in_version": "58",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 20,