Add probing histograms.

This CL adds a handful of histograms that track how many probes we send, and some details about
them.

We'll track the total number of requested probe clusters and how many of them timed out, recorded
when we destroy the prober. For the successful clusters we'll also track how many bytes it took,
how many packets we sent and how long it took to send.

Bug: webrtc:10413
Change-Id: I4a223caa6d3c2829a36788d4fa615a41286b183f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127884
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27270}
diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn
index 00fde9e..26e60c9 100644
--- a/modules/pacing/BUILD.gn
+++ b/modules/pacing/BUILD.gn
@@ -42,6 +42,7 @@
     "../../rtc_base/experiments:field_trial_parser",
     "../../system_wrappers",
     "../../system_wrappers:field_trial",
+    "../../system_wrappers:metrics",
     "../congestion_controller/goog_cc:alr_detector",
     "../remote_bitrate_estimator",
     "../rtp_rtcp",
diff --git a/modules/pacing/bitrate_prober.cc b/modules/pacing/bitrate_prober.cc
index 890eb7b..c81a18c 100644
--- a/modules/pacing/bitrate_prober.cc
+++ b/modules/pacing/bitrate_prober.cc
@@ -18,6 +18,7 @@
 #include "logging/rtc_event_log/rtc_event_log.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
+#include "system_wrappers/include/metrics.h"
 
 namespace webrtc {
 
@@ -47,11 +48,19 @@
 
 BitrateProber::BitrateProber() : BitrateProber(nullptr) {}
 
-BitrateProber::~BitrateProber() = default;
+BitrateProber::~BitrateProber() {
+  RTC_HISTOGRAM_COUNTS_1000("WebRTC.BWE.Probing.TotalProbeClustersRequested",
+                            total_probe_count_);
+  RTC_HISTOGRAM_COUNTS_1000("WebRTC.BWE.Probing.TotalFailedProbeClusters",
+                            total_failed_probe_count_);
+}
 
 // TODO(psla): Remove this constructor in a follow up change.
 BitrateProber::BitrateProber(RtcEventLog* event_log)
-    : probing_state_(ProbingState::kDisabled), next_probe_time_ms_(-1) {
+    : probing_state_(ProbingState::kDisabled),
+      next_probe_time_ms_(-1),
+      total_probe_count_(0),
+      total_failed_probe_count_(0) {
   SetEnabled(true);
 }
 
@@ -88,9 +97,12 @@
                                        int cluster_id) {
   RTC_DCHECK(probing_state_ != ProbingState::kDisabled);
   RTC_DCHECK_GT(bitrate_bps, 0);
+
+  total_probe_count_++;
   while (!clusters_.empty() &&
          now_ms - clusters_.front().time_created_ms > kProbeClusterTimeoutMs) {
     clusters_.pop();
+    total_failed_probe_count_++;
   }
 
   ProbeCluster cluster;
@@ -162,6 +174,13 @@
     next_probe_time_ms_ = GetNextProbeTime(*cluster);
     if (cluster->sent_bytes >= cluster->pace_info.probe_cluster_min_bytes &&
         cluster->sent_probes >= cluster->pace_info.probe_cluster_min_probes) {
+      RTC_HISTOGRAM_COUNTS_100000("WebRTC.BWE.Probing.ProbeClusterSizeInBytes",
+                                  cluster->sent_bytes);
+      RTC_HISTOGRAM_COUNTS_100("WebRTC.BWE.Probing.ProbesPerCluster",
+                               cluster->sent_probes);
+      RTC_HISTOGRAM_COUNTS_10000("WebRTC.BWE.Probing.TimePerProbeCluster",
+                                 now_ms - cluster->time_started_ms);
+
       clusters_.pop();
     }
     if (clusters_.empty())
diff --git a/modules/pacing/bitrate_prober.h b/modules/pacing/bitrate_prober.h
index a8e964c..e970eee 100644
--- a/modules/pacing/bitrate_prober.h
+++ b/modules/pacing/bitrate_prober.h
@@ -98,6 +98,9 @@
 
   // Time the next probe should be sent when in kActive state.
   int64_t next_probe_time_ms_;
+
+  int total_probe_count_;
+  int total_failed_probe_count_;
 };
 
 }  // namespace webrtc