Migration from QUIC_BUG to QUIC_BUG_V2(bug_id).

Per go/gfe-bug-improvements GFE_BUGs are getting stable IDs to allow for monitoring and alerting. Existing QUIC_BUG instances are changed to have `quic_bug_n_m` ID, where `n` is unique for each file, and `m` is a counter within each file, so we get `QUIC_BUG_V2(quic_bug_123_2)`

PiperOrigin-RevId: 361607447
Change-Id: I7c430eeb831ff92fdcdc867945d691e3bfff7e72
diff --git a/quic/core/quic_packet_creator.cc b/quic/core/quic_packet_creator.cc
index d5f7912..82922f1 100644
--- a/quic/core/quic_packet_creator.cc
+++ b/quic/core/quic_packet_creator.cc
@@ -51,7 +51,7 @@
           << level;
       return INVALID_PACKET_TYPE;
     default:
-      QUIC_BUG << level;
+      QUIC_BUG_V2(quic_bug_10752_1) << level;
       return INVALID_PACKET_TYPE;
   }
 }
@@ -194,9 +194,10 @@
 void QuicPacketCreator::SetSoftMaxPacketLength(QuicByteCount length) {
   QUICHE_DCHECK(CanSetMaxPacketLength());
   if (length > max_packet_length_) {
-    QUIC_BUG << ENDPOINT
-             << "Try to increase max_packet_length_ in "
-                "SetSoftMaxPacketLength, use SetMaxPacketLength instead.";
+    QUIC_BUG_V2(quic_bug_10752_2)
+        << ENDPOINT
+        << "Try to increase max_packet_length_ in "
+           "SetSoftMaxPacketLength, use SetMaxPacketLength instead.";
     return;
   }
   if (framer_->GetMaxPlaintextSize(length) <
@@ -238,10 +239,10 @@
     QuicPacketCount max_packets_in_flight) {
   if (!queued_frames_.empty()) {
     // Don't change creator state if there are frames queued.
-    QUIC_BUG << "Called UpdatePacketNumberLength with " << queued_frames_.size()
-             << " queued_frames.  First frame type:"
-             << queued_frames_.front().type
-             << " last frame type:" << queued_frames_.back().type;
+    QUIC_BUG_V2(quic_bug_10752_3)
+        << "Called UpdatePacketNumberLength with " << queued_frames_.size()
+        << " queued_frames.  First frame type:" << queued_frames_.front().type
+        << " last frame type:" << queued_frames_.back().type;
     return;
   }
 
@@ -271,10 +272,10 @@
     QuicPacketCount max_packets_in_flight) {
   if (!queued_frames_.empty()) {
     // Don't change creator state if there are frames queued.
-    QUIC_BUG << "Called SkipNPacketNumbers with " << queued_frames_.size()
-             << " queued_frames.  First frame type:"
-             << queued_frames_.front().type
-             << " last frame type:" << queued_frames_.back().type;
+    QUIC_BUG_V2(quic_bug_10752_4)
+        << "Called SkipNPacketNumbers with " << queued_frames_.size()
+        << " queued_frames.  First frame type:" << queued_frames_.front().type
+        << " last frame type:" << queued_frames_.back().type;
     return;
   }
   if (packet_.packet_number > packet_.packet_number + count) {
@@ -336,9 +337,9 @@
       frame->stream_frame.data_length < data_size) {
     const std::string error_details =
         "Client hello won't fit in a single packet.";
-    QUIC_BUG << error_details << " Constructed stream frame length: "
-             << frame->stream_frame.data_length
-             << " CHLO length: " << data_size;
+    QUIC_BUG_V2(quic_bug_10752_5)
+        << error_details << " Constructed stream frame length: "
+        << frame->stream_frame.data_length << " CHLO length: " << data_size;
     delegate_->OnUnrecoverableError(QUIC_CRYPTO_CHLO_TOO_LARGE, error_details);
     return false;
   }
@@ -522,13 +523,13 @@
       packet.packet_number_length, packet.encryption_level, &packet_);
   for (const QuicFrame& frame : packet.nonretransmittable_frames) {
     if (!AddFrame(frame, packet.transmission_type)) {
-      QUIC_BUG << "Failed to serialize frame: " << frame;
+      QUIC_BUG_V2(quic_bug_10752_6) << "Failed to serialize frame: " << frame;
       return 0;
     }
   }
   for (const QuicFrame& frame : packet.retransmittable_frames) {
     if (!AddFrame(frame, packet.transmission_type)) {
-      QUIC_BUG << "Failed to serialize frame: " << frame;
+      QUIC_BUG_V2(quic_bug_10752_7) << "Failed to serialize frame: " << frame;
       return 0;
     }
   }
@@ -537,9 +538,10 @@
     QUIC_DVLOG(2) << ENDPOINT << "Add padding of size: " << padding_size;
     if (!AddFrame(QuicFrame(QuicPaddingFrame(padding_size)),
                   packet.transmission_type)) {
-      QUIC_BUG << "Failed to add padding of size " << padding_size
-               << " when serializing ENCRYPTION_INITIAL "
-                  "packet in coalesced packet";
+      QUIC_BUG_V2(quic_bug_10752_8)
+          << "Failed to add padding of size " << padding_size
+          << " when serializing ENCRYPTION_INITIAL "
+             "packet in coalesced packet";
       return 0;
     }
   }
@@ -588,7 +590,7 @@
   QuicDataWriter writer(kMaxOutgoingPacketSize, encrypted_buffer);
   size_t length_field_offset = 0;
   if (!framer_->AppendPacketHeader(header, &writer, &length_field_offset)) {
-    QUIC_BUG << "AppendPacketHeader failed";
+    QUIC_BUG_V2(quic_bug_10752_9) << "AppendPacketHeader failed";
     return;
   }
 
@@ -629,18 +631,18 @@
   // into one method that takes a QuicStreamFrame, if warranted.
   bool omit_frame_length = !needs_padding;
   if (!framer_->AppendTypeByte(QuicFrame(frame), omit_frame_length, &writer)) {
-    QUIC_BUG << "AppendTypeByte failed";
+    QUIC_BUG_V2(quic_bug_10752_10) << "AppendTypeByte failed";
     return;
   }
   if (!framer_->AppendStreamFrame(frame, omit_frame_length, &writer)) {
-    QUIC_BUG << "AppendStreamFrame failed";
+    QUIC_BUG_V2(quic_bug_10752_11) << "AppendStreamFrame failed";
     return;
   }
   if (needs_padding &&
       plaintext_bytes_written < MinPlaintextPacketSize(framer_->version()) &&
       !writer.WritePaddingBytes(MinPlaintextPacketSize(framer_->version()) -
                                 plaintext_bytes_written)) {
-    QUIC_BUG << "Unable to add padding bytes";
+    QUIC_BUG_V2(quic_bug_10752_12) << "Unable to add padding bytes";
     return;
   }
 
@@ -659,7 +661,8 @@
       GetStartOfEncryptedData(framer_->transport_version(), header),
       writer.length(), kMaxOutgoingPacketSize, encrypted_buffer);
   if (encrypted_length == 0) {
-    QUIC_BUG << "Failed to encrypt packet number " << header.packet_number;
+    QUIC_BUG_V2(quic_bug_10752_13)
+        << "Failed to encrypt packet number " << header.packet_number;
     return;
   }
   // TODO(ianswett): Optimize the storage so RetransmitableFrames can be
@@ -745,7 +748,7 @@
   if (packet_.encrypted_buffer != nullptr) {
     const std::string error_details =
         "Packet's encrypted buffer is not empty before serialization";
-    QUIC_BUG << error_details;
+    QUIC_BUG_V2(quic_bug_10752_14) << error_details;
     delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET,
                                     error_details);
     return false;
@@ -778,10 +781,10 @@
   if (!framer_->HasEncrypterOfEncryptionLevel(packet_.encryption_level)) {
     // TODO(fayang): Use QUIC_MISSING_WRITE_KEYS for serialization failures due
     // to missing keys.
-    QUIC_BUG << ENDPOINT << "Attempting to serialize " << header
-             << QuicFramesToString(queued_frames_)
-             << " at missing encryption_level " << packet_.encryption_level
-             << " using " << framer_->version();
+    QUIC_BUG_V2(quic_bug_10752_15)
+        << ENDPOINT << "Attempting to serialize " << header
+        << QuicFramesToString(queued_frames_) << " at missing encryption_level "
+        << packet_.encryption_level << " using " << framer_->version();
     return false;
   }
 
@@ -792,14 +795,15 @@
       framer_->BuildDataPacket(header, queued_frames_, encrypted_buffer.buffer,
                                packet_size_, packet_.encryption_level);
   if (length == 0) {
-    QUIC_BUG << "Failed to serialize " << QuicFramesToString(queued_frames_)
-             << " at encryption_level: " << packet_.encryption_level
-             << ", needs_full_padding_: " << needs_full_padding_
-             << ", pending_padding_bytes_: " << pending_padding_bytes_
-             << ", latched_hard_max_packet_length_: "
-             << latched_hard_max_packet_length_
-             << ", max_packet_length_: " << max_packet_length_
-             << ", header: " << header;
+    QUIC_BUG_V2(quic_bug_10752_16)
+        << "Failed to serialize " << QuicFramesToString(queued_frames_)
+        << " at encryption_level: " << packet_.encryption_level
+        << ", needs_full_padding_: " << needs_full_padding_
+        << ", pending_padding_bytes_: " << pending_padding_bytes_
+        << ", latched_hard_max_packet_length_: "
+        << latched_hard_max_packet_length_
+        << ", max_packet_length_: " << max_packet_length_
+        << ", header: " << header;
     return false;
   }
 
@@ -820,7 +824,8 @@
       GetStartOfEncryptedData(framer_->transport_version(), header), length,
       encrypted_buffer_len, encrypted_buffer.buffer);
   if (encrypted_length == 0) {
-    QUIC_BUG << "Failed to encrypt packet number " << packet_.packet_number;
+    QUIC_BUG_V2(quic_bug_10752_17)
+        << "Failed to encrypt packet number " << packet_.packet_number;
     return false;
   }
 
@@ -1042,7 +1047,8 @@
     char* buffer,
     size_t buffer_len) {
   if (HasPendingFrames()) {
-    QUIC_BUG << "Try to serialize coalesced packet with pending frames";
+    QUIC_BUG_V2(quic_bug_10752_18)
+        << "Try to serialize coalesced packet with pending frames";
     return 0;
   }
   RemoveSoftMaxPacketLength();
@@ -1062,8 +1068,9 @@
     size_t initial_length = ReserializeInitialPacketInCoalescedPacket(
         *coalesced.initial_packet(), padding_size, buffer, buffer_len);
     if (initial_length == 0) {
-      QUIC_BUG << "Failed to reserialize ENCRYPTION_INITIAL packet in "
-                  "coalesced packet";
+      QUIC_BUG_V2(quic_bug_10752_19)
+          << "Failed to reserialize ENCRYPTION_INITIAL packet in "
+             "coalesced packet";
       return 0;
     }
     buffer += initial_length;
@@ -1206,8 +1213,9 @@
     return false;
   }
   const bool success = AddFrame(frame, next_transmission_type_);
-  QUIC_BUG_IF(!success) << "Failed to add frame:" << frame
-                        << " transmission_type:" << next_transmission_type_;
+  QUIC_BUG_IF_V2(quic_bug_10752_20, !success)
+      << "Failed to add frame:" << frame
+      << " transmission_type:" << next_transmission_type_;
   return success;
 }
 
@@ -1215,8 +1223,9 @@
                                                 size_t write_length,
                                                 QuicStreamOffset offset,
                                                 StreamSendingState state) {
-  QUIC_BUG_IF(!flusher_attached_) << "Packet flusher is not attached when "
-                                     "generator tries to write stream data.";
+  QUIC_BUG_IF_V2(quic_bug_10752_21, !flusher_attached_)
+      << "Packet flusher is not attached when "
+         "generator tries to write stream data.";
   bool has_handshake = QuicUtils::IsCryptoStreamId(transport_version(), id);
   MaybeBundleAckOpportunistically();
   bool fin = state != NO_FIN;
@@ -1236,7 +1245,8 @@
   }
 
   if (!fin && (write_length == 0)) {
-    QUIC_BUG << "Attempt to consume empty data without FIN.";
+    QUIC_BUG_V2(quic_bug_10752_22)
+        << "Attempt to consume empty data without FIN.";
     return QuicConsumedData(0, false);
   }
   // We determine if we can enter the fast path before executing
@@ -1259,7 +1269,7 @@
                                         next_transmission_type_, &frame)) {
       // The creator is always flushed if there's not enough room for a new
       // stream frame before ConsumeData, so ConsumeData should always succeed.
-      QUIC_BUG << "Failed to ConsumeData, stream:" << id;
+      QUIC_BUG_V2(quic_bug_10752_23) << "Failed to ConsumeData, stream:" << id;
       return QuicConsumedData(0, false);
     }
 
@@ -1323,7 +1333,7 @@
     if (bytes_consumed == 0) {
       const std::string error_details =
           "Failed in CreateAndSerializeStreamFrame.";
-      QUIC_BUG << error_details;
+      QUIC_BUG_V2(quic_bug_10752_24) << error_details;
       delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET,
                                       error_details);
       break;
@@ -1340,8 +1350,9 @@
                                             QuicStreamOffset offset) {
   QUIC_DVLOG(2) << "ConsumeCryptoData " << level << " write_length "
                 << write_length << " offset " << offset;
-  QUIC_BUG_IF(!flusher_attached_) << "Packet flusher is not attached when "
-                                     "generator tries to write crypto data.";
+  QUIC_BUG_IF_V2(quic_bug_10752_25, !flusher_attached_)
+      << "Packet flusher is not attached when "
+         "generator tries to write crypto data.";
   MaybeBundleAckOpportunistically();
   // To make reasoning about crypto frames easier, we don't combine them with
   // other retransmittable frames in a single packet.
@@ -1365,7 +1376,8 @@
       // The only pending data in the packet is non-retransmittable frames. I'm
       // assuming here that they won't occupy so much of the packet that a
       // CRYPTO frame won't fit.
-      QUIC_BUG << "Failed to ConsumeCryptoData at level " << level;
+      QUIC_BUG_V2(quic_bug_10752_26)
+          << "Failed to ConsumeCryptoData at level " << level;
       return 0;
     }
     total_bytes_consumed += frame.crypto_frame->data_length;
@@ -1381,8 +1393,9 @@
 void QuicPacketCreator::GenerateMtuDiscoveryPacket(QuicByteCount target_mtu) {
   // MTU discovery frames must be sent by themselves.
   if (!CanSetMaxPacketLength()) {
-    QUIC_BUG << "MTU discovery packets should only be sent when no other "
-             << "frames needs to be sent.";
+    QUIC_BUG_V2(quic_bug_10752_27)
+        << "MTU discovery packets should only be sent when no other "
+        << "frames needs to be sent.";
     return;
   }
   const QuicByteCount current_mtu = max_packet_length();
@@ -1398,8 +1411,9 @@
   FlushCurrentPacket();
   // The only reason AddFrame can fail is that the packet is too full to fit in
   // a ping.  This is not possible for any sane MTU.
-  QUIC_BUG_IF(!success) << "Failed to send path MTU target_mtu:" << target_mtu
-                        << " transmission_type:" << next_transmission_type_;
+  QUIC_BUG_IF_V2(quic_bug_10752_28, !success)
+      << "Failed to send path MTU target_mtu:" << target_mtu
+      << " transmission_type:" << next_transmission_type_;
 
   // Reset the packet length back.
   SetMaxPacketLength(current_mtu);
@@ -1416,13 +1430,15 @@
   }
   const bool flushed =
       FlushAckFrame(delegate_->MaybeBundleAckOpportunistically());
-  QUIC_BUG_IF(!flushed) << "Failed to flush ACK frame. encryption_level:"
-                        << packet_.encryption_level;
+  QUIC_BUG_IF_V2(quic_bug_10752_29, !flushed)
+      << "Failed to flush ACK frame. encryption_level:"
+      << packet_.encryption_level;
 }
 
 bool QuicPacketCreator::FlushAckFrame(const QuicFrames& frames) {
-  QUIC_BUG_IF(!flusher_attached_) << "Packet flusher is not attached when "
-                                     "generator tries to send ACK frame.";
+  QUIC_BUG_IF_V2(quic_bug_10752_30, !flusher_attached_)
+      << "Packet flusher is not attached when "
+         "generator tries to send ACK frame.";
   // MaybeBundleAckOpportunistically could be called nestedly when sending a
   // control frame causing another control frame to be sent.
   QUIC_BUG_IF(GetQuicReloadableFlag(quic_single_ack_in_packet2) &&
@@ -1444,7 +1460,7 @@
       return false;
     }
     const bool success = AddFrame(frame, next_transmission_type_);
-    QUIC_BUG_IF(!success) << "Failed to flush " << frame;
+    QUIC_BUG_IF_V2(quic_bug_10752_31, !success) << "Failed to flush " << frame;
   }
   return true;
 }
@@ -1466,7 +1482,8 @@
   flusher_attached_ = false;
   if (GetQuicFlag(FLAGS_quic_export_write_path_stats_at_server)) {
     if (!write_start_packet_number_.IsInitialized()) {
-      QUIC_BUG << "write_start_packet_number is not initialized";
+      QUIC_BUG_V2(quic_bug_10752_32)
+          << "write_start_packet_number is not initialized";
       return;
     }
     QUIC_SERVER_HISTOGRAM_COUNTS(
@@ -1499,8 +1516,9 @@
 
 MessageStatus QuicPacketCreator::AddMessageFrame(QuicMessageId message_id,
                                                  QuicMemSliceSpan message) {
-  QUIC_BUG_IF(!flusher_attached_) << "Packet flusher is not attached when "
-                                     "generator tries to add message frame.";
+  QUIC_BUG_IF_V2(quic_bug_10752_33, !flusher_attached_)
+      << "Packet flusher is not attached when "
+         "generator tries to add message frame.";
   MaybeBundleAckOpportunistically();
   const QuicByteCount message_length = message.total_length();
   if (message_length > GetCurrentLargestMessagePayload()) {
@@ -1512,7 +1530,7 @@
   QuicMessageFrame* frame = new QuicMessageFrame(message_id, message);
   const bool success = AddFrame(QuicFrame(frame), next_transmission_type_);
   if (!success) {
-    QUIC_BUG << "Failed to send message " << message_id;
+    QUIC_BUG_V2(quic_bug_10752_34) << "Failed to send message " << message_id;
     delete frame;
     return MESSAGE_STATUS_INTERNAL_ERROR;
   }
@@ -1576,7 +1594,8 @@
     return serialized_frame_length;
   }
   if (BytesFree() < serialized_frame_length) {
-    QUIC_BUG << ENDPOINT << "Frame does not fit: " << frame;
+    QUIC_BUG_V2(quic_bug_10752_35)
+        << ENDPOINT << "Frame does not fit: " << frame;
     return 0;
   }
   // Please note bytes_free does not take |frame|'s expansion into account.
@@ -1790,8 +1809,9 @@
 
   bool success = AddFrame(QuicFrame(QuicPaddingFrame(padding_bytes)),
                           packet_.transmission_type);
-  QUIC_BUG_IF(!success) << "Failed to add padding_bytes: " << padding_bytes
-                        << " transmission_type: " << packet_.transmission_type;
+  QUIC_BUG_IF_V2(quic_bug_10752_36, !success)
+      << "Failed to add padding_bytes: " << padding_bytes
+      << " transmission_type: " << packet_.transmission_type;
 }
 
 bool QuicPacketCreator::IncludeNonceInPublicHeader() const {
@@ -1916,7 +1936,7 @@
   const std::string error_details =
       absl::StrCat("Cannot send stream data with level: ",
                    EncryptionLevelToString(packet_.encryption_level));
-  QUIC_BUG << error_details;
+  QUIC_BUG_V2(quic_bug_10752_37) << error_details;
   delegate_->OnUnrecoverableError(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA,
                                   error_details);
   return true;
@@ -2009,7 +2029,7 @@
 
   if (creator_->packet_.encrypted_buffer == nullptr) {
     const std::string error_details = "Failed to SerializePacket.";
-    QUIC_BUG << error_details;
+    QUIC_BUG_V2(quic_bug_10752_38) << error_details;
     creator_->delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET,
                                               error_details);
   }
diff --git a/quic/core/quic_packet_reader.cc b/quic/core/quic_packet_reader.cc
index 4b0eb4b..312bc8d 100644
--- a/quic/core/quic_packet_reader.cc
+++ b/quic/core/quic_packet_reader.cc
@@ -67,7 +67,7 @@
     }
 
     if (!result.packet_info.HasValue(QuicUdpPacketInfoBit::PEER_ADDRESS)) {
-      QUIC_BUG << "Unable to get peer socket address.";
+      QUIC_BUG_V2(quic_bug_10329_1) << "Unable to get peer socket address.";
       continue;
     }
 
@@ -77,7 +77,7 @@
     QuicIpAddress self_ip = GetSelfIpFromPacketInfo(
         result.packet_info, peer_address.host().IsIPv6());
     if (!self_ip.IsInitialized()) {
-      QUIC_BUG << "Unable to get self IP address.";
+      QUIC_BUG_V2(quic_bug_10329_2) << "Unable to get self IP address.";
       continue;
     }
 
diff --git a/quic/core/quic_path_validator.cc b/quic/core/quic_path_validator.cc
index f2abef0..ec2c902 100644
--- a/quic/core/quic_path_validator.cc
+++ b/quic/core/quic_path_validator.cc
@@ -72,7 +72,8 @@
   QUIC_DLOG(INFO) << "Start validating path " << *context
                   << " via writer: " << context->WriterToUse();
   if (path_context_ != nullptr) {
-    QUIC_BUG << "There is an on-going validation on path " << *path_context_;
+    QUIC_BUG_V2(quic_bug_10876_1)
+        << "There is an on-going validation on path " << *path_context_;
     ResetPathValidation();
   }
 
diff --git a/quic/core/quic_received_packet_manager.cc b/quic/core/quic_received_packet_manager.cc
index 2b43442..2157ae3 100644
--- a/quic/core/quic_received_packet_manager.cc
+++ b/quic/core/quic_received_packet_manager.cc
@@ -309,7 +309,7 @@
 QuicPacketNumber QuicReceivedPacketManager::PeerFirstSendingPacketNumber()
     const {
   if (!least_received_packet_number_.IsInitialized()) {
-    QUIC_BUG << "No packets have been received yet";
+    QUIC_BUG_V2(quic_bug_10849_1) << "No packets have been received yet";
     return QuicPacketNumber(1);
   }
   return least_received_packet_number_;
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc
index ce0ccf4..b1970c8 100644
--- a/quic/core/quic_sent_packet_manager.cc
+++ b/quic/core/quic_sent_packet_manager.cc
@@ -776,7 +776,8 @@
     const {
   QuicAckFrequencyFrame frame;
   if (!CanSendAckFrequency()) {
-    QUIC_BUG << "New AckFrequencyFrame is created while it shouldn't.";
+    QUIC_BUG_V2(quic_bug_10750_1)
+        << "New AckFrequencyFrame is created while it shouldn't.";
     return frame;
   }
 
@@ -804,7 +805,8 @@
   QuicPacketNumber packet_number = packet.packet_number;
   QUICHE_DCHECK_LE(FirstSendingPacketNumber(), packet_number);
   QUICHE_DCHECK(!unacked_packets_.IsUnacked(packet_number));
-  QUIC_BUG_IF(packet.encrypted_length == 0) << "Cannot send empty packets.";
+  QUIC_BUG_IF_V2(quic_bug_10750_2, packet.encrypted_length == 0)
+      << "Cannot send empty packets.";
   if (pending_timer_transmission_count_ > 0) {
     --pending_timer_transmission_count_;
   }
@@ -895,7 +897,8 @@
       pending_timer_transmission_count_ = max_probe_packets_per_pto_;
       return PTO_MODE;
   }
-  QUIC_BUG << "Unknown retransmission mode " << GetRetransmissionMode();
+  QUIC_BUG_V2(quic_bug_10750_3)
+      << "Unknown retransmission mode " << GetRetransmissionMode();
   return GetRetransmissionMode();
 }
 
@@ -1188,8 +1191,8 @@
       unacked_packets_.GetTransmissionInfo(largest_acked);
   // Ensure the packet has a valid sent time.
   if (transmission_info.sent_time == QuicTime::Zero()) {
-    QUIC_BUG << "Acked packet has zero sent time, largest_acked:"
-             << largest_acked;
+    QUIC_BUG_V2(quic_bug_10750_4)
+        << "Acked packet has zero sent time, largest_acked:" << largest_acked;
     return false;
   }
   if (transmission_info.state == NOT_CONTRIBUTING_RTT) {
@@ -1591,16 +1594,18 @@
         unacked_packets_.GetMutableTransmissionInfo(acked_packet.packet_number);
     if (!QuicUtils::IsAckable(info->state)) {
       if (info->state == ACKED) {
-        QUIC_BUG << "Trying to ack an already acked packet: "
-                 << acked_packet.packet_number
-                 << ", last_ack_frame_: " << last_ack_frame_
-                 << ", least_unacked: " << unacked_packets_.GetLeastUnacked()
-                 << ", packets_acked_: " << packets_acked_;
+        QUIC_BUG_V2(quic_bug_10750_5)
+            << "Trying to ack an already acked packet: "
+            << acked_packet.packet_number
+            << ", last_ack_frame_: " << last_ack_frame_
+            << ", least_unacked: " << unacked_packets_.GetLeastUnacked()
+            << ", packets_acked_: " << packets_acked_;
       } else {
-        QUIC_PEER_BUG << "Received " << ack_decrypted_level
-                      << " ack for unackable packet: "
-                      << acked_packet.packet_number << " with state: "
-                      << QuicUtils::SentPacketStateToString(info->state);
+        QUIC_PEER_BUG_V2(quic_peer_bug_10750_6)
+            << "Received " << ack_decrypted_level
+            << " ack for unackable packet: " << acked_packet.packet_number
+            << " with state: "
+            << QuicUtils::SentPacketStateToString(info->state);
         if (supports_multiple_packet_number_spaces()) {
           if (info->state == NEVER_SENT) {
             return UNSENT_PACKETS_ACKED;
@@ -1804,7 +1809,7 @@
     in_use_sent_ack_delays_.pop_front_n(stale_entry_count);
   }
   if (in_use_sent_ack_delays_.empty()) {
-    QUIC_BUG << "in_use_sent_ack_delays_ is empty.";
+    QUIC_BUG_V2(quic_bug_10750_7) << "in_use_sent_ack_delays_ is empty.";
     return;
   }
   peer_max_ack_delay_ = std::max_element(in_use_sent_ack_delays_.cbegin(),
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 10b2025..5296162 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -614,11 +614,12 @@
     if (!(write_blocked_streams_.HasWriteBlockedSpecialStream() ||
           write_blocked_streams_.HasWriteBlockedDataStreams())) {
       // Writing one stream removed another!? Something's broken.
-      QUIC_BUG << "WriteBlockedStream is missing, num_writes: " << num_writes
-               << ", finished_writes: " << i
-               << ", connected: " << connection_->connected()
-               << ", connection level flow control blocked: "
-               << flow_controller_.IsBlocked();
+      QUIC_BUG_V2(quic_bug_10866_1)
+          << "WriteBlockedStream is missing, num_writes: " << num_writes
+          << ", finished_writes: " << i
+          << ", connected: " << connection_->connected()
+          << ", connection level flow control blocked: "
+          << flow_controller_.IsBlocked();
       for (QuicStreamId id : last_writing_stream_ids) {
         QUIC_LOG(WARNING) << "last_writing_stream_id: " << id;
       }
@@ -760,8 +761,9 @@
           << ENDPOINT << "Try to send new data on stream " << id
           << "before 1-RTT keys are available while 0-RTT is rejected.";
     } else {
-      QUIC_BUG << ENDPOINT << "Try to send data of stream " << id
-               << " before encryption is established.";
+      QUIC_BUG_V2(quic_bug_10866_2)
+          << ENDPOINT << "Try to send data of stream " << id
+          << " before encryption is established.";
     }
     return QuicConsumedData(0, false);
   }
@@ -804,7 +806,7 @@
     const std::string error_details = absl::StrCat(
         "Try to send crypto data with missing keys of encryption level: ",
         EncryptionLevelToString(level));
-    QUIC_BUG << ENDPOINT << error_details;
+    QUIC_BUG_V2(quic_bug_10866_3) << ENDPOINT << error_details;
     connection()->CloseConnection(
         QUIC_MISSING_WRITE_KEYS, error_details,
         ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
@@ -840,8 +842,9 @@
   if (connection_->encrypted_control_frames()) {
     QUIC_RELOADABLE_FLAG_COUNT(quic_encrypted_control_frames);
     if (!IsEncryptionEstablished()) {
-      QUIC_BUG << ENDPOINT << "Tried to send control frame " << frame
-               << " before encryption is established.";
+      QUIC_BUG_V2(quic_bug_10866_4)
+          << ENDPOINT << "Tried to send control frame " << frame
+          << " before encryption is established.";
       return false;
     }
   }
@@ -953,7 +956,8 @@
 void QuicSession::SendMaxStreams(QuicStreamCount stream_count,
                                  bool unidirectional) {
   if (!is_configured_) {
-    QUIC_BUG << "Try to send max streams before config negotiated.";
+    QUIC_BUG_V2(quic_bug_10866_5)
+        << "Try to send max streams before config negotiated.";
     return;
   }
   control_frame_manager_.WriteOrBufferMaxStreams(stream_count, unidirectional);
@@ -969,7 +973,8 @@
   QUIC_DVLOG(1) << ENDPOINT << "Closing stream: " << stream_id;
   StreamMap::iterator it = stream_map_.find(stream_id);
   if (it == stream_map_.end()) {
-    QUIC_BUG << ENDPOINT << "Stream is already closed: " << stream_id;
+    QUIC_BUG_V2(quic_bug_10866_6)
+        << ENDPOINT << "Stream is already closed: " << stream_id;
     return;
   }
   QuicStream* stream = it->second.get();
@@ -1613,7 +1618,7 @@
           connection()->clock()->ApproximateNow();
       break;
     default:
-      QUIC_BUG << "Unknown encryption level: " << level;
+      QUIC_BUG_V2(quic_bug_10866_7) << "Unknown encryption level: " << level;
   }
 }
 
@@ -1678,11 +1683,13 @@
     case ENCRYPTION_ZERO_RTT:
       break;
     case ENCRYPTION_FORWARD_SECURE:
-      QUIC_BUG << ENDPOINT << "Discarding 1-RTT keys is not allowed";
+      QUIC_BUG_V2(quic_bug_10866_8)
+          << ENDPOINT << "Discarding 1-RTT keys is not allowed";
       break;
     default:
-      QUIC_BUG << ENDPOINT
-               << "Cannot discard keys for unknown encryption level: " << level;
+      QUIC_BUG_V2(quic_bug_10866_9)
+          << ENDPOINT
+          << "Cannot discard keys for unknown encryption level: " << level;
   }
 }
 
@@ -1696,7 +1703,8 @@
   was_zero_rtt_rejected_ = true;
   connection_->MarkZeroRttPacketsForRetransmission(reason);
   if (connection_->encryption_level() == ENCRYPTION_FORWARD_SECURE) {
-    QUIC_BUG << "1-RTT keys already available when 0-RTT is rejected.";
+    QUIC_BUG_V2(quic_bug_10866_10)
+        << "1-RTT keys already available when 0-RTT is rejected.";
     connection_->CloseConnection(
         QUIC_INTERNAL_ERROR,
         "1-RTT keys already available when 0-RTT is rejected.",
@@ -2029,7 +2037,8 @@
 
 void QuicSession::MarkConnectionLevelWriteBlocked(QuicStreamId id) {
   if (GetOrCreateStream(id) == nullptr) {
-    QUIC_BUG << "Marking unknown stream " << id << " blocked.";
+    QUIC_BUG_V2(quic_bug_10866_11)
+        << "Marking unknown stream " << id << " blocked.";
     QUIC_LOG_FIRST_N(ERROR, 2) << QuicStackTrace();
   }
 
@@ -2184,8 +2193,9 @@
 void QuicSession::OnStreamFrameRetransmitted(const QuicStreamFrame& frame) {
   QuicStream* stream = GetStream(frame.stream_id);
   if (stream == nullptr) {
-    QUIC_BUG << "Stream: " << frame.stream_id << " is closed when " << frame
-             << " is retransmitted.";
+    QUIC_BUG_V2(quic_bug_10866_12)
+        << "Stream: " << frame.stream_id << " is closed when " << frame
+        << " is retransmitted.";
     connection()->CloseConnection(
         QUIC_INTERNAL_ERROR, "Attempt to retransmit frame of a closed stream",
         ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
@@ -2296,8 +2306,9 @@
   if (stream == nullptr) {
     // This causes the connection to be closed because of failed to serialize
     // packet.
-    QUIC_BUG << "Stream " << id << " does not exist when trying to write data."
-             << " version:" << transport_version();
+    QUIC_BUG_V2(quic_bug_10866_13)
+        << "Stream " << id << " does not exist when trying to write data."
+        << " version:" << transport_version();
     return STREAM_MISSING;
   }
   if (stream->WriteStreamData(offset, data_length, writer)) {
@@ -2382,7 +2393,8 @@
         streams_with_pending_retransmission_.pop_front();
       }
     } else {
-      QUIC_BUG << "Try to retransmit data of a closed stream";
+      QUIC_BUG_V2(quic_bug_10866_14)
+          << "Try to retransmit data of a closed stream";
       streams_with_pending_retransmission_.pop_front();
     }
   }
diff --git a/quic/core/quic_stream.cc b/quic/core/quic_stream.cc
index b8ac8cc..50e0776 100644
--- a/quic/core/quic_stream.cc
+++ b/quic/core/quic_stream.cc
@@ -424,10 +424,10 @@
       (kMaxStreamLength - frame.offset < frame.data_length);
   if (is_stream_too_long) {
     // Close connection if stream becomes too long.
-    QUIC_PEER_BUG << "Receive stream frame on stream " << id_
-                  << " reaches max stream length. frame offset " << frame.offset
-                  << " length " << frame.data_length << ". "
-                  << sequencer_.DebugString();
+    QUIC_PEER_BUG_V2(quic_peer_bug_10586_1)
+        << "Receive stream frame on stream " << id_
+        << " reaches max stream length. frame offset " << frame.offset
+        << " length " << frame.data_length << ". " << sequencer_.DebugString();
     OnUnrecoverableError(
         QUIC_STREAM_LENGTH_OVERFLOW,
         absl::StrCat("Peer sends more data than allowed on stream ", id_,
@@ -648,12 +648,12 @@
     absl::optional<EncryptionLevel> level,
     QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) {
   if (data.empty() && !fin) {
-    QUIC_BUG << "data.empty() && !fin";
+    QUIC_BUG_V2(quic_bug_10586_2) << "data.empty() && !fin";
     return;
   }
 
   if (fin_buffered_) {
-    QUIC_BUG << "Fin already buffered";
+    QUIC_BUG_V2(quic_bug_10586_3) << "Fin already buffered";
     return;
   }
   if (write_side_closed_) {
@@ -675,7 +675,7 @@
     struct iovec iov(QuicUtils::MakeIovec(data));
     QuicStreamOffset offset = send_buffer_.stream_offset();
     if (kMaxStreamLength - offset < data.length()) {
-      QUIC_BUG << "Write too many data via stream " << id_;
+      QUIC_BUG_V2(quic_bug_10586_4) << "Write too many data via stream " << id_;
       OnUnrecoverableError(
           QUIC_STREAM_LENGTH_OVERFLOW,
           absl::StrCat("Write too many data via stream ", id_));
@@ -734,8 +734,8 @@
 
 void QuicStream::MaybeSendBlocked() {
   if (!flow_controller_.has_value()) {
-    QUIC_BUG << ENDPOINT
-             << "MaybeSendBlocked called on stream without flow control";
+    QUIC_BUG_V2(quic_bug_10586_5)
+        << ENDPOINT << "MaybeSendBlocked called on stream without flow control";
     return;
   }
   if (flow_controller_->ShouldSendBlocked()) {
@@ -760,12 +760,12 @@
 QuicConsumedData QuicStream::WriteMemSlices(QuicMemSliceSpan span, bool fin) {
   QuicConsumedData consumed_data(0, false);
   if (span.empty() && !fin) {
-    QUIC_BUG << "span.empty() && !fin";
+    QUIC_BUG_V2(quic_bug_10586_6) << "span.empty() && !fin";
     return consumed_data;
   }
 
   if (fin_buffered_) {
-    QUIC_BUG << "Fin already buffered";
+    QUIC_BUG_V2(quic_bug_10586_7) << "Fin already buffered";
     return consumed_data;
   }
 
@@ -788,7 +788,8 @@
       consumed_data.bytes_consumed = send_buffer_.SaveMemSliceSpan(span);
       if (offset > send_buffer_.stream_offset() ||
           kMaxStreamLength < send_buffer_.stream_offset()) {
-        QUIC_BUG << "Write too many data via stream " << id_;
+        QUIC_BUG_V2(quic_bug_10586_8)
+            << "Write too many data via stream " << id_;
         OnUnrecoverableError(
             QUIC_STREAM_LENGTH_OVERFLOW,
             absl::StrCat("Write too many data via stream ", id_));
@@ -949,8 +950,9 @@
   }
 
   if (!flow_controller_.has_value()) {
-    QUIC_BUG << ENDPOINT
-             << "OnWindowUpdateFrame called on stream without flow control";
+    QUIC_BUG_V2(quic_bug_10586_9)
+        << ENDPOINT
+        << "OnWindowUpdateFrame called on stream without flow control";
     return;
   }
 
@@ -963,9 +965,10 @@
 bool QuicStream::MaybeIncreaseHighestReceivedOffset(
     QuicStreamOffset new_offset) {
   if (!flow_controller_.has_value()) {
-    QUIC_BUG << ENDPOINT
-             << "MaybeIncreaseHighestReceivedOffset called on stream without "
-                "flow control";
+    QUIC_BUG_V2(quic_bug_10586_10)
+        << ENDPOINT
+        << "MaybeIncreaseHighestReceivedOffset called on stream without "
+           "flow control";
     return false;
   }
   uint64_t increment =
@@ -987,8 +990,8 @@
 
 void QuicStream::AddBytesSent(QuicByteCount bytes) {
   if (!flow_controller_.has_value()) {
-    QUIC_BUG << ENDPOINT
-             << "AddBytesSent called on stream without flow control";
+    QUIC_BUG_V2(quic_bug_10586_11)
+        << ENDPOINT << "AddBytesSent called on stream without flow control";
     return;
   }
   flow_controller_->AddBytesSent(bytes);
@@ -1023,8 +1026,9 @@
 bool QuicStream::MaybeConfigSendWindowOffset(QuicStreamOffset new_offset,
                                              bool was_zero_rtt_rejected) {
   if (!flow_controller_.has_value()) {
-    QUIC_BUG << ENDPOINT
-             << "ConfigSendWindowOffset called on stream without flow control";
+    QUIC_BUG_V2(quic_bug_10586_12)
+        << ENDPOINT
+        << "ConfigSendWindowOffset called on stream without flow control";
     return false;
   }
 
@@ -1227,8 +1231,9 @@
     send_window = flow_controller_->SendWindowSize();
   } else {
     send_window = std::numeric_limits<QuicByteCount>::max();
-    QUIC_BUG << ENDPOINT
-             << "WriteBufferedData called on stream without flow control";
+    QUIC_BUG_V2(quic_bug_10586_13)
+        << ENDPOINT
+        << "WriteBufferedData called on stream without flow control";
   }
   if (stream_contributes_to_connection_flow_control_) {
     send_window =
@@ -1370,7 +1375,7 @@
 
 bool QuicStream::MaybeSetTtl(QuicTime::Delta ttl) {
   if (is_static_) {
-    QUIC_BUG << "Cannot set TTL of a static stream.";
+    QUIC_BUG_V2(quic_bug_10586_14) << "Cannot set TTL of a static stream.";
     return false;
   }
   if (deadline_.IsInitialized()) {
@@ -1402,7 +1407,8 @@
 
 bool QuicStream::IsFlowControlBlocked() const {
   if (!flow_controller_.has_value()) {
-    QUIC_BUG << "Trying to access non-existent flow controller.";
+    QUIC_BUG_V2(quic_bug_10586_15)
+        << "Trying to access non-existent flow controller.";
     return false;
   }
   return flow_controller_->IsBlocked();
@@ -1410,7 +1416,8 @@
 
 QuicStreamOffset QuicStream::highest_received_byte_offset() const {
   if (!flow_controller_.has_value()) {
-    QUIC_BUG << "Trying to access non-existent flow controller.";
+    QUIC_BUG_V2(quic_bug_10586_16)
+        << "Trying to access non-existent flow controller.";
     return 0;
   }
   return flow_controller_->highest_received_byte_offset();
@@ -1418,7 +1425,8 @@
 
 void QuicStream::UpdateReceiveWindowSize(QuicStreamOffset size) {
   if (!flow_controller_.has_value()) {
-    QUIC_BUG << "Trying to access non-existent flow controller.";
+    QUIC_BUG_V2(quic_bug_10586_17)
+        << "Trying to access non-existent flow controller.";
     return;
   }
   flow_controller_->UpdateReceiveWindowSize(size);
diff --git a/quic/core/quic_stream_send_buffer.cc b/quic/core/quic_stream_send_buffer.cc
index 219eacd..01a43fb 100644
--- a/quic/core/quic_stream_send_buffer.cc
+++ b/quic/core/quic_stream_send_buffer.cc
@@ -77,7 +77,8 @@
   QUIC_DVLOG(2) << "Save slice offset " << stream_offset_ << " length "
                 << slice.length();
   if (slice.empty()) {
-    QUIC_BUG << "Try to save empty MemSlice to send buffer.";
+    QUIC_BUG_V2(quic_bug_10853_1)
+        << "Try to save empty MemSlice to send buffer.";
     return;
   }
   size_t length = slice.length();
@@ -122,7 +123,7 @@
     QuicByteCount copy_length = std::min(data_length, available_bytes_in_slice);
     if (!writer->WriteBytes(slice_it->slice.data() + slice_offset,
                             copy_length)) {
-      QUIC_BUG << "Writer fails to write.";
+      QUIC_BUG_V2(quic_bug_10853_2) << "Writer fails to write.";
       return false;
     }
     offset += copy_length;
@@ -219,8 +220,9 @@
     const auto pending = pending_retransmissions_.begin();
     return {pending->min(), pending->max() - pending->min()};
   }
-  QUIC_BUG << "NextPendingRetransmission is called unexpected with no "
-              "pending retransmissions.";
+  QUIC_BUG_V2(quic_bug_10853_3)
+      << "NextPendingRetransmission is called unexpected with no "
+         "pending retransmissions.";
   return {0, 0};
 }
 
@@ -228,10 +230,11 @@
                                          QuicStreamOffset end) {
   auto it = interval_deque_.DataBegin();
   if (it == interval_deque_.DataEnd() || it->slice.empty()) {
-    QUIC_BUG << "Trying to ack stream data [" << start << ", " << end << "), "
-             << (it == interval_deque_.DataEnd()
-                     ? "and there is no outstanding data."
-                     : "and the first slice is empty.");
+    QUIC_BUG_V2(quic_bug_10853_4)
+        << "Trying to ack stream data [" << start << ", " << end << "), "
+        << (it == interval_deque_.DataEnd()
+                ? "and there is no outstanding data."
+                : "and the first slice is empty.");
     return false;
   }
   if (!it->interval().Contains(start)) {
@@ -240,9 +243,10 @@
                           interval_deque_.DataEnd(), start, CompareOffset());
   }
   if (it == interval_deque_.DataEnd() || it->slice.empty()) {
-    QUIC_BUG << "Offset " << start << " with iterator offset: " << it->offset
-             << (it == interval_deque_.DataEnd() ? " does not exist."
-                                                 : " has already been acked.");
+    QUIC_BUG_V2(quic_bug_10853_5)
+        << "Offset " << start << " with iterator offset: " << it->offset
+        << (it == interval_deque_.DataEnd() ? " does not exist."
+                                            : " has already been acked.");
     return false;
   }
   for (; it != interval_deque_.DataEnd(); ++it) {
diff --git a/quic/core/quic_stream_sequencer.cc b/quic/core/quic_stream_sequencer.cc
index e702f71..d4b39a4 100644
--- a/quic/core/quic_stream_sequencer.cc
+++ b/quic/core/quic_stream_sequencer.cc
@@ -40,8 +40,8 @@
 
 QuicStreamSequencer::~QuicStreamSequencer() {
   if (stream_ == nullptr) {
-    QUIC_BUG << "Double free'ing QuicStreamSequencer at " << this << ". "
-             << QuicStackTrace();
+    QUIC_BUG_V2(quic_bug_10858_1) << "Double free'ing QuicStreamSequencer at "
+                                  << this << ". " << QuicStackTrace();
   }
   stream_ = nullptr;
 }
@@ -235,9 +235,10 @@
   QUICHE_DCHECK(!blocked_);
   bool result = buffered_frames_.MarkConsumed(num_bytes_consumed);
   if (!result) {
-    QUIC_BUG << "Invalid argument to MarkConsumed."
-             << " expect to consume: " << num_bytes_consumed
-             << ", but not enough bytes available. " << DebugString();
+    QUIC_BUG_V2(quic_bug_10858_2)
+        << "Invalid argument to MarkConsumed."
+        << " expect to consume: " << num_bytes_consumed
+        << ", but not enough bytes available. " << DebugString();
     stream_->Reset(QUIC_ERROR_PROCESSING_STREAM);
     return;
   }
diff --git a/quic/core/quic_stream_sequencer_buffer.cc b/quic/core/quic_stream_sequencer_buffer.cc
index 5c85a6e..9ac7f5f 100644
--- a/quic/core/quic_stream_sequencer_buffer.cc
+++ b/quic/core/quic_stream_sequencer_buffer.cc
@@ -73,7 +73,7 @@
 
 bool QuicStreamSequencerBuffer::RetireBlock(size_t index) {
   if (blocks_[index] == nullptr) {
-    QUIC_BUG << "Try to retire block twice";
+    QUIC_BUG_V2(quic_bug_10610_1) << "Try to retire block twice";
     return false;
   }
   delete blocks_[index];
@@ -516,7 +516,7 @@
         return true;
       }
     } else {
-      QUIC_BUG << "Read stopped at where it shouldn't.";
+      QUIC_BUG_V2(quic_bug_10610_2) << "Read stopped at where it shouldn't.";
       return false;
     }
   }