Add QPACK logging for each encoded header list to track whether encoding is blocked.

gfe-relnote: n/a, change to QUIC v99-only code.  Protected by existing disabled gfe2_reloadable_flag_quic_enable_version_99.
PiperOrigin-RevId: 272023695
Change-Id: I180a4e29d04c5786fabfb1b5d297b353e4d9104a
diff --git a/quic/core/qpack/qpack_encoder.cc b/quic/core/qpack/qpack_encoder.cc
index bd16f36..e7593dc 100644
--- a/quic/core/qpack/qpack_encoder.cc
+++ b/quic/core/qpack/qpack_encoder.cc
@@ -36,7 +36,8 @@
     : decoder_stream_error_delegate_(decoder_stream_error_delegate),
       decoder_stream_receiver_(this),
       maximum_blocked_streams_(0),
-      debug_visitor_(nullptr) {
+      debug_visitor_(nullptr),
+      header_list_count_(0) {
   DCHECK(decoder_stream_error_delegate_);
 }
 
@@ -288,6 +289,44 @@
   }
 
   if (debug_visitor_) {
+    ++header_list_count_;
+
+    if (dynamic_table_insertion_blocked) {
+      QUIC_HISTOGRAM_COUNTS(
+          "QuicSession.Qpack.HeaderListCountWhenInsertionBlocked",
+          header_list_count_, /* min = */ 1, /* max = */ 1000,
+          /* bucket_count = */ 50,
+          "The ordinality of a header list within a connection during the "
+          "encoding of which at least one dynamic table insertion was "
+          "blocked.");
+    } else {
+      QUIC_HISTOGRAM_COUNTS(
+          "QuicSession.Qpack.HeaderListCountWhenInsertionNotBlocked",
+          header_list_count_, /* min = */ 1, /* max = */ 1000,
+          /* bucket_count = */ 50,
+          "The ordinality of a header list within a connection during the "
+          "encoding of which no dynamic table insertion was blocked.");
+    }
+
+    if (blocked_stream_limit_exhausted) {
+      QUIC_HISTOGRAM_COUNTS(
+          "QuicSession.Qpack.HeaderListCountWhenBlockedStreamLimited",
+          header_list_count_, /* min = */ 1, /* max = */ 1000,
+          /* bucket_count = */ 50,
+          "The ordinality of a header list within a connection during the "
+          "encoding of which unacknowledged dynamic table entries could not be "
+          "referenced due to the limit on the number of blocked streams.");
+    } else {
+      QUIC_HISTOGRAM_COUNTS(
+          "QuicSession.Qpack.HeaderListCountWhenNotBlockedStreamLimited",
+          header_list_count_, /* min = */ 1, /* max = */ 1000,
+          /* bucket_count = */ 50,
+          "The ordinality of a header list within a connection during the "
+          "encoding of which the limit on the number of blocked streams did "
+          "not "
+          "prevent referencing unacknowledged dynamic table entries.");
+    }
+
     debug_visitor_->OnHeaderListEncoded(dynamic_table_insertion_blocked,
                                         blocked_stream_limit_exhausted);
   }
diff --git a/quic/core/qpack/qpack_encoder.h b/quic/core/qpack/qpack_encoder.h
index c4aaced..6060798 100644
--- a/quic/core/qpack/qpack_encoder.h
+++ b/quic/core/qpack/qpack_encoder.h
@@ -16,6 +16,7 @@
 #include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h"
 #include "net/third_party/quiche/src/quic/core/quic_types.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
 
 namespace spdy {
@@ -171,7 +172,9 @@
   QpackHeaderTable header_table_;
   uint64_t maximum_blocked_streams_;
   QpackBlockingManager blocking_manager_;
+  // TODO(bnc): Remove |debug_visitor_|.
   DebugVisitor* debug_visitor_;
+  int header_list_count_;
 };
 
 }  // namespace quic