gfe-relnote: (n/a) Add a bunch of logging to debug b/151424244. Logging only, not protected.

PiperOrigin-RevId: 301902641
Change-Id: I5be7202ee41dc166d0aacc406fdd95f6ef90b525
diff --git a/quic/core/congestion_control/bandwidth_sampler.cc b/quic/core/congestion_control/bandwidth_sampler.cc
index 37a49a1..c78c6b7 100644
--- a/quic/core/congestion_control/bandwidth_sampler.cc
+++ b/quic/core/congestion_control/bandwidth_sampler.cc
@@ -14,6 +14,15 @@
 
 namespace quic {
 
+std::ostream& operator<<(std::ostream& os, const SendTimeState& s) {
+  os << "{valid:" << s.is_valid << ", app_limited:" << s.is_app_limited
+     << ", total_sent:" << s.total_bytes_sent
+     << ", total_acked:" << s.total_bytes_acked
+     << ", total_lost:" << s.total_bytes_lost
+     << ", inflight:" << s.bytes_in_flight << "}";
+  return os;
+}
+
 QuicByteCount MaxAckHeightTracker::Update(QuicBandwidth bandwidth_estimate,
                                           QuicRoundTripCount round_trip_count,
                                           QuicTime ack_time,
@@ -353,7 +362,11 @@
     QUIC_BUG << "Time of the previously acked packet:"
              << a0.ack_time.ToDebuggingValue()
              << " is larger than the ack time of the current packet:"
-             << ack_time.ToDebuggingValue();
+             << ack_time.ToDebuggingValue()
+             << ". acked packet number:" << packet_number
+             << ", total_bytes_acked_:" << total_bytes_acked_
+             << ", overestimate_avoidance_:" << overestimate_avoidance_
+             << ", sent_packet:" << sent_packet;
     return BandwidthSample();
   }
   QuicBandwidth ack_rate = QuicBandwidth::FromBytesAndTimeDelta(
@@ -368,7 +381,12 @@
   SentPacketToSendTimeState(sent_packet, &sample.state_at_send);
 
   QUIC_BUG_IF(sample.bandwidth.IsZero())
-      << "ack_rate: " << ack_rate << ", send_rate: " << send_rate;
+      << "ack_rate: " << ack_rate << ", send_rate: " << send_rate
+      << ". acked packet number:" << packet_number
+      << ", overestimate_avoidance_:" << overestimate_avoidance_ << "a1:{"
+      << total_bytes_acked_ << "@" << ack_time << "}, a0:{"
+      << a0.total_bytes_acked << "@" << a0.ack_time
+      << "}, sent_packet:" << sent_packet;
   return sample;
 }
 
diff --git a/quic/core/congestion_control/bandwidth_sampler.h b/quic/core/congestion_control/bandwidth_sampler.h
index 0a69447..2f00d62 100644
--- a/quic/core/congestion_control/bandwidth_sampler.h
+++ b/quic/core/congestion_control/bandwidth_sampler.h
@@ -48,6 +48,9 @@
 
   SendTimeState(const SendTimeState& other) = default;
 
+  friend QUIC_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
+                                                      const SendTimeState& s);
+
   // Whether other states in this object is valid.
   bool is_valid;
 
@@ -456,6 +459,18 @@
           total_bytes_sent_at_last_acked_packet(0),
           last_acked_packet_sent_time(QuicTime::Zero()),
           last_acked_packet_ack_time(QuicTime::Zero()) {}
+
+    friend QUIC_EXPORT_PRIVATE std::ostream& operator<<(
+        std::ostream& os,
+        const ConnectionStateOnSentPacket& p) {
+      os << "{sent_time:" << p.sent_time << ", size:" << p.size
+         << ", total_bytes_sent_at_last_acked_packet:"
+         << p.total_bytes_sent_at_last_acked_packet
+         << ", last_acked_packet_sent_time:" << p.last_acked_packet_sent_time
+         << ", last_acked_packet_ack_time:" << p.last_acked_packet_ack_time
+         << ", send_time_state:" << p.send_time_state << "}";
+      return os;
+    }
   };
 
   BandwidthSample OnPacketAcknowledged(QuicTime ack_time,