Record the frequency of stream frame coalescing at QuicSession.CoalesceStreamFrameStatus.

gfe-relnote: protected by gfe2_reloadable_flag_quic_log_coalesce_stream_frame_frequency
PiperOrigin-RevId: 287199998
Change-Id: I1c4cf9177d0764c77704ebc20e2615dc5a31260e
diff --git a/quic/core/quic_packet_creator.cc b/quic/core/quic_packet_creator.cc
index 2f9d46e..d272068 100644
--- a/quic/core/quic_packet_creator.cc
+++ b/quic/core/quic_packet_creator.cc
@@ -22,6 +22,7 @@
 #include "net/third_party/quiche/src/quic/core/quic_versions.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_aligned.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
@@ -53,6 +54,14 @@
   }
 }
 
+void LogCoalesceStreamFrameStatus(bool success) {
+  if (GetQuicReloadableFlag(quic_log_coalesce_stream_frame_frequency)) {
+    QUIC_RELOADABLE_FLAG_COUNT(quic_log_coalesce_stream_frame_frequency);
+    QUIC_HISTOGRAM_BOOL("QuicSession.CoalesceStreamFrameStatus", success,
+                        "Success rate of coalesing stream frames attempt.");
+  }
+}
+
 // ScopedPacketContextSwitcher saves |packet|'s states and change states
 // during its construction. When the switcher goes out of scope, it restores
 // saved states.
@@ -1445,10 +1454,14 @@
   }
 
   if (GetQuicRestartFlag(quic_coalesce_stream_frames_2) &&
-      frame.type == STREAM_FRAME &&
-      MaybeCoalesceStreamFrame(frame.stream_frame)) {
-    QUIC_RESTART_FLAG_COUNT_N(quic_coalesce_stream_frames_2, 1, 3);
-    return true;
+      frame.type == STREAM_FRAME) {
+    if (MaybeCoalesceStreamFrame(frame.stream_frame)) {
+      LogCoalesceStreamFrameStatus(true);
+      QUIC_RESTART_FLAG_COUNT_N(quic_coalesce_stream_frames_2, 1, 3);
+      return true;
+    } else {
+      LogCoalesceStreamFrameStatus(false);
+    }
   }
 
   size_t frame_len = framer_->GetSerializedFrameLength(