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: 361916454
Change-Id: I8f512cf57b9ee4c84ada9a7f023686fd1c381ce1
diff --git a/quic/core/packet_number_indexed_queue.h b/quic/core/packet_number_indexed_queue.h
index eec75df..cf0f8de 100644
--- a/quic/core/packet_number_indexed_queue.h
+++ b/quic/core/packet_number_indexed_queue.h
@@ -147,7 +147,8 @@
 bool PacketNumberIndexedQueue<T>::Emplace(QuicPacketNumber packet_number,
                                           Args&&... args) {
   if (!packet_number.IsInitialized()) {
-    QUIC_BUG << "Try to insert an uninitialized packet number";
+    QUIC_BUG_V2(quic_bug_10359_1)
+        << "Try to insert an uninitialized packet number";
     return false;
   }
 
diff --git a/quic/core/quic_buffered_packet_store.cc b/quic/core/quic_buffered_packet_store.cc
index b9e3d10..8fa53b0 100644
--- a/quic/core/quic_buffered_packet_store.cc
+++ b/quic/core/quic_buffered_packet_store.cc
@@ -262,8 +262,8 @@
   QUICHE_DCHECK_EQ(version.handshake_protocol, PROTOCOL_TLS1_3);
   auto it = undecryptable_packets_.find(connection_id);
   if (it == undecryptable_packets_.end()) {
-    QUIC_BUG << "Cannot ingest packet for unknown connection ID "
-             << connection_id;
+    QUIC_BUG_V2(quic_bug_10838_1)
+        << "Cannot ingest packet for unknown connection ID " << connection_id;
     return false;
   }
   it->second.tls_chlo_extractor.IngestPacket(version, packet);
diff --git a/quic/core/quic_coalesced_packet.cc b/quic/core/quic_coalesced_packet.cc
index 28f3ece..547e089 100644
--- a/quic/core/quic_coalesced_packet.cc
+++ b/quic/core/quic_coalesced_packet.cc
@@ -24,7 +24,7 @@
     QuicBufferAllocator* allocator,
     QuicPacketLength current_max_packet_length) {
   if (packet.encrypted_length == 0) {
-    QUIC_BUG << "Trying to coalesce an empty packet";
+    QUIC_BUG_V2(quic_bug_10611_1) << "Trying to coalesce an empty packet";
     return true;
   }
   if (length_ == 0) {
@@ -47,7 +47,8 @@
       return false;
     }
     if (max_packet_length_ != current_max_packet_length) {
-      QUIC_BUG << "Max packet length changes in the middle of the write path";
+      QUIC_BUG_V2(quic_bug_10611_2)
+          << "Max packet length changes in the middle of the write path";
       return false;
     }
     if (ContainsPacketOfEncryptionLevel(packet.encryption_level)) {
@@ -102,9 +103,9 @@
     return;
   }
   if (length_ < initial_packet_->encrypted_length) {
-    QUIC_BUG << "length_: " << length_
-             << ", is less than initial packet length: "
-             << initial_packet_->encrypted_length;
+    QUIC_BUG_V2(quic_bug_10611_3)
+        << "length_: " << length_ << ", is less than initial packet length: "
+        << initial_packet_->encrypted_length;
     Clear();
     return;
   }
@@ -145,8 +146,9 @@
 TransmissionType QuicCoalescedPacket::TransmissionTypeOfPacket(
     EncryptionLevel level) const {
   if (!ContainsPacketOfEncryptionLevel(level)) {
-    QUIC_BUG << "Coalesced packet does not contain packet of encryption level: "
-             << EncryptionLevelToString(level);
+    QUIC_BUG_V2(quic_bug_10611_4)
+        << "Coalesced packet does not contain packet of encryption level: "
+        << EncryptionLevelToString(level);
     return NOT_RETRANSMISSION;
   }
   return transmission_types_[level];
diff --git a/quic/core/quic_config.cc b/quic/core/quic_config.cc
index 893d822..76145c0 100644
--- a/quic/core/quic_config.cc
+++ b/quic/core/quic_config.cc
@@ -116,7 +116,7 @@
   if (tag_ == 0) {
     *error_details =
         "This parameter does not support reading from CryptoHandshakeMessage";
-    QUIC_BUG << *error_details;
+    QUIC_BUG_V2(quic_bug_10575_1) << *error_details;
     return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND;
   }
   QuicErrorCode error = peer_hello.GetUint32(tag_, &receive_value_);
@@ -150,7 +150,8 @@
 
 uint64_t QuicFixedUint62::GetSendValue() const {
   if (!has_send_value_) {
-    QUIC_BUG << "No send value to get for tag:" << QuicTagToString(tag_);
+    QUIC_BUG_V2(quic_bug_10575_2)
+        << "No send value to get for tag:" << QuicTagToString(tag_);
     return 0;
   }
   return send_value_;
@@ -158,7 +159,7 @@
 
 void QuicFixedUint62::SetSendValue(uint64_t value) {
   if (value > kVarInt62MaxValue) {
-    QUIC_BUG << "QuicFixedUint62 invalid value " << value;
+    QUIC_BUG_V2(quic_bug_10575_3) << "QuicFixedUint62 invalid value " << value;
     value = kVarInt62MaxValue;
   }
   has_send_value_ = true;
@@ -171,7 +172,8 @@
 
 uint64_t QuicFixedUint62::GetReceivedValue() const {
   if (!has_receive_value_) {
-    QUIC_BUG << "No receive value to get for tag:" << QuicTagToString(tag_);
+    QUIC_BUG_V2(quic_bug_10575_4)
+        << "No receive value to get for tag:" << QuicTagToString(tag_);
     return 0;
   }
   return receive_value_;
@@ -188,8 +190,8 @@
   }
   uint32_t send_value32;
   if (send_value_ > std::numeric_limits<uint32_t>::max()) {
-    QUIC_BUG << "Attempting to send " << send_value_
-             << " for tag:" << QuicTagToString(tag_);
+    QUIC_BUG_V2(quic_bug_10575_5) << "Attempting to send " << send_value_
+                                  << " for tag:" << QuicTagToString(tag_);
     send_value32 = std::numeric_limits<uint32_t>::max();
   } else {
     send_value32 = static_cast<uint32_t>(send_value_);
@@ -544,7 +546,8 @@
 
 void QuicConfig::SetIdleNetworkTimeout(QuicTime::Delta idle_network_timeout) {
   if (idle_network_timeout.ToMicroseconds() <= 0) {
-    QUIC_BUG << "Invalid idle network timeout " << idle_network_timeout;
+    QUIC_BUG_V2(quic_bug_10575_6)
+        << "Invalid idle network timeout " << idle_network_timeout;
     return;
   }
   max_idle_timeout_to_send_ = idle_network_timeout;
@@ -729,9 +732,10 @@
 void QuicConfig::SetInitialStreamFlowControlWindowToSend(
     uint64_t window_bytes) {
   if (window_bytes < kMinimumFlowControlSendWindow) {
-    QUIC_BUG << "Initial stream flow control receive window (" << window_bytes
-             << ") cannot be set lower than minimum ("
-             << kMinimumFlowControlSendWindow << ").";
+    QUIC_BUG_V2(quic_bug_10575_7)
+        << "Initial stream flow control receive window (" << window_bytes
+        << ") cannot be set lower than minimum ("
+        << kMinimumFlowControlSendWindow << ").";
     window_bytes = kMinimumFlowControlSendWindow;
   }
   initial_stream_flow_control_window_bytes_.SetSendValue(window_bytes);
@@ -824,9 +828,10 @@
 void QuicConfig::SetInitialSessionFlowControlWindowToSend(
     uint64_t window_bytes) {
   if (window_bytes < kMinimumFlowControlSendWindow) {
-    QUIC_BUG << "Initial session flow control receive window (" << window_bytes
-             << ") cannot be set lower than default ("
-             << kMinimumFlowControlSendWindow << ").";
+    QUIC_BUG_V2(quic_bug_10575_8)
+        << "Initial session flow control receive window (" << window_bytes
+        << ") cannot be set lower than default ("
+        << kMinimumFlowControlSendWindow << ").";
     window_bytes = kMinimumFlowControlSendWindow;
   }
   initial_session_flow_control_window_bytes_.SetSendValue(window_bytes);
@@ -871,8 +876,9 @@
 void QuicConfig::SetIPv6AlternateServerAddressToSend(
     const QuicSocketAddress& alternate_server_address_ipv6) {
   if (!alternate_server_address_ipv6.host().IsIPv6()) {
-    QUIC_BUG << "Cannot use SetIPv6AlternateServerAddressToSend with "
-             << alternate_server_address_ipv6;
+    QUIC_BUG_V2(quic_bug_10575_9)
+        << "Cannot use SetIPv6AlternateServerAddressToSend with "
+        << alternate_server_address_ipv6;
     return;
   }
   alternate_server_address_ipv6_.SetSendValue(alternate_server_address_ipv6);
@@ -883,8 +889,9 @@
     const QuicConnectionId& connection_id,
     QuicUint128 stateless_reset_token) {
   if (!alternate_server_address_ipv6.host().IsIPv6()) {
-    QUIC_BUG << "Cannot use SetIPv6AlternateServerAddressToSend with "
-             << alternate_server_address_ipv6;
+    QUIC_BUG_V2(quic_bug_10575_10)
+        << "Cannot use SetIPv6AlternateServerAddressToSend with "
+        << alternate_server_address_ipv6;
     return;
   }
   alternate_server_address_ipv6_.SetSendValue(alternate_server_address_ipv6);
@@ -904,8 +911,9 @@
 void QuicConfig::SetIPv4AlternateServerAddressToSend(
     const QuicSocketAddress& alternate_server_address_ipv4) {
   if (!alternate_server_address_ipv4.host().IsIPv4()) {
-    QUIC_BUG << "Cannot use SetIPv4AlternateServerAddressToSend with "
-             << alternate_server_address_ipv4;
+    QUIC_BUG_V2(quic_bug_10575_11)
+        << "Cannot use SetIPv4AlternateServerAddressToSend with "
+        << alternate_server_address_ipv4;
     return;
   }
   alternate_server_address_ipv4_.SetSendValue(alternate_server_address_ipv4);
@@ -916,8 +924,9 @@
     const QuicConnectionId& connection_id,
     QuicUint128 stateless_reset_token) {
   if (!alternate_server_address_ipv4.host().IsIPv4()) {
-    QUIC_BUG << "Cannot use SetIPv4AlternateServerAddressToSend with "
-             << alternate_server_address_ipv4;
+    QUIC_BUG_V2(quic_bug_10575_12)
+        << "Cannot use SetIPv4AlternateServerAddressToSend with "
+        << alternate_server_address_ipv4;
     return;
   }
   alternate_server_address_ipv4_.SetSendValue(alternate_server_address_ipv4);
@@ -958,7 +967,7 @@
 
 QuicConnectionId QuicConfig::ReceivedOriginalConnectionId() const {
   if (!HasReceivedOriginalConnectionId()) {
-    QUIC_BUG << "No received original connection ID";
+    QUIC_BUG_V2(quic_bug_10575_13) << "No received original connection ID";
     return EmptyQuicConnectionId();
   }
   return received_original_destination_connection_id_.value();
@@ -975,7 +984,8 @@
 
 QuicConnectionId QuicConfig::ReceivedInitialSourceConnectionId() const {
   if (!HasReceivedInitialSourceConnectionId()) {
-    QUIC_BUG << "No received initial source connection ID";
+    QUIC_BUG_V2(quic_bug_10575_14)
+        << "No received initial source connection ID";
     return EmptyQuicConnectionId();
   }
   return received_initial_source_connection_id_.value();
@@ -992,7 +1002,7 @@
 
 QuicConnectionId QuicConfig::ReceivedRetrySourceConnectionId() const {
   if (!HasReceivedRetrySourceConnectionId()) {
-    QUIC_BUG << "No received retry source connection ID";
+    QUIC_BUG_V2(quic_bug_10575_15) << "No received retry source connection ID";
     return EmptyQuicConnectionId();
   }
   return received_retry_source_connection_id_.value();
@@ -1312,8 +1322,8 @@
   if (!is_resumption && !params.stateless_reset_token.empty()) {
     QuicUint128 stateless_reset_token;
     if (params.stateless_reset_token.size() != sizeof(stateless_reset_token)) {
-      QUIC_BUG << "Bad stateless reset token length "
-               << params.stateless_reset_token.size();
+      QUIC_BUG_V2(quic_bug_10575_16) << "Bad stateless reset token length "
+                                     << params.stateless_reset_token.size();
       *error_details = "Bad stateless reset token length";
       return QUIC_INTERNAL_ERROR;
     }
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 52dbccc..271576a 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -724,11 +724,13 @@
 void QuicConnection::EnableLegacyVersionEncapsulation(
     const std::string& server_name) {
   if (perspective_ != Perspective::IS_CLIENT) {
-    QUIC_BUG << "Cannot enable Legacy Version Encapsulation on the server";
+    QUIC_BUG_V2(quic_bug_10511_1)
+        << "Cannot enable Legacy Version Encapsulation on the server";
     return;
   }
   if (legacy_version_encapsulation_enabled_) {
-    QUIC_BUG << "Do not call EnableLegacyVersionEncapsulation twice";
+    QUIC_BUG_V2(quic_bug_10511_2)
+        << "Do not call EnableLegacyVersionEncapsulation twice";
     return;
   }
   if (!QuicHostnameUtils::IsValidSNI(server_name)) {
@@ -884,7 +886,7 @@
                   << ParsedQuicVersionToString(received_version);
   if (perspective_ == Perspective::IS_CLIENT) {
     const std::string error_details = "Protocol version mismatch.";
-    QUIC_BUG << ENDPOINT << error_details;
+    QUIC_BUG_V2(quic_bug_10511_3) << ENDPOINT << error_details;
     CloseConnection(QUIC_INTERNAL_ERROR, error_details,
                     ConnectionCloseBehavior::SILENT_CLOSE);
   }
@@ -904,7 +906,7 @@
   if (perspective_ == Perspective::IS_SERVER) {
     const std::string error_details =
         "Server received version negotiation packet.";
-    QUIC_BUG << error_details;
+    QUIC_BUG_V2(quic_bug_10511_4) << error_details;
     QUIC_CODE_COUNT(quic_tear_down_local_connection_on_version_negotiation);
     CloseConnection(QUIC_INTERNAL_ERROR, error_details,
                     ConnectionCloseBehavior::SILENT_CLOSE);
@@ -1116,7 +1118,8 @@
     const std::string error_details =
         "Pending frames must be serialized before incoming packets are "
         "processed.";
-    QUIC_BUG << error_details << ", received header: " << header;
+    QUIC_BUG_V2(quic_bug_10511_5)
+        << error_details << ", received header: " << header;
     CloseConnection(QUIC_INTERNAL_ERROR, error_details,
                     ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
     return false;
@@ -1319,11 +1322,11 @@
       return false;
     }
 
-    QUIC_PEER_BUG << ENDPOINT
-                  << "Received an unencrypted data frame: closing connection"
-                  << " packet_number:" << last_header_.packet_number
-                  << " stream_id:" << frame.stream_id
-                  << " received_packets:" << ack_frame();
+    QUIC_PEER_BUG_V2(quic_peer_bug_10511_6)
+        << ENDPOINT << "Received an unencrypted data frame: closing connection"
+        << " packet_number:" << last_header_.packet_number
+        << " stream_id:" << frame.stream_id
+        << " received_packets:" << ack_frame();
     CloseConnection(QUIC_UNENCRYPTED_STREAM_DATA,
                     "Unencrypted stream data seen.",
                     ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
@@ -1422,9 +1425,10 @@
 
 bool QuicConnection::OnAckTimestamp(QuicPacketNumber packet_number,
                                     QuicTime timestamp) {
-  QUIC_BUG_IF(!connected_) << "Processing ACK frame time stamp when connection "
-                              "is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_7, !connected_)
+      << "Processing ACK frame time stamp when connection "
+         "is closed. Last frame: "
+      << most_recent_frame_type_;
   QUIC_DVLOG(1) << ENDPOINT << "OnAckTimestamp: [" << packet_number << ", "
                 << timestamp.ToDebuggingValue() << ")";
 
@@ -1659,9 +1663,10 @@
 };
 
 bool QuicConnection::OnPathChallengeFrame(const QuicPathChallengeFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing PATH_CHALLENGE frame when connection "
-                              "is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_8, !connected_)
+      << "Processing PATH_CHALLENGE frame when connection "
+         "is closed. Last frame: "
+      << most_recent_frame_type_;
   if (has_path_challenge_in_current_packet_) {
     QUICHE_DCHECK(send_path_response_);
     QUIC_RELOADABLE_FLAG_COUNT_N(quic_send_path_response2, 2, 5);
@@ -1724,9 +1729,10 @@
 }
 
 bool QuicConnection::OnPathResponseFrame(const QuicPathResponseFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing PATH_RESPONSE frame when connection "
-                              "is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_9, !connected_)
+      << "Processing PATH_RESPONSE frame when connection "
+         "is closed. Last frame: "
+      << most_recent_frame_type_;
   if (!UpdatePacketContent(PATH_RESPONSE_FRAME)) {
     return false;
   }
@@ -1752,9 +1758,10 @@
 
 bool QuicConnection::OnConnectionCloseFrame(
     const QuicConnectionCloseFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing CONNECTION_CLOSE frame when "
-                              "connection is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_10, !connected_)
+      << "Processing CONNECTION_CLOSE frame when "
+         "connection is closed. Last frame: "
+      << most_recent_frame_type_;
 
   // Since a connection close frame was received, this is not a connectivity
   // probe. A probe only contains a PING and full padding.
@@ -1817,9 +1824,10 @@
 
 bool QuicConnection::OnStreamsBlockedFrame(
     const QuicStreamsBlockedFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing STREAMS_BLOCKED frame when "
-                              "connection is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_11, !connected_)
+      << "Processing STREAMS_BLOCKED frame when "
+         "connection is closed. Last frame: "
+      << most_recent_frame_type_;
   if (!UpdatePacketContent(STREAMS_BLOCKED_FRAME)) {
     return false;
   }
@@ -1854,9 +1862,10 @@
 }
 
 bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing WINDOW_UPDATE frame when connection "
-                              "is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_12, !connected_)
+      << "Processing WINDOW_UPDATE frame when connection "
+         "is closed. Last frame: "
+      << most_recent_frame_type_;
 
   // Since a window update frame was received, this is not a connectivity probe.
   // A probe only contains a PING and full padding.
@@ -1898,9 +1907,10 @@
 
 bool QuicConnection::OnNewConnectionIdFrame(
     const QuicNewConnectionIdFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing NEW_CONNECTION_ID frame when "
-                              "connection is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_13, !connected_)
+      << "Processing NEW_CONNECTION_ID frame when "
+         "connection is closed. Last frame: "
+      << most_recent_frame_type_;
   if (!UpdatePacketContent(NEW_CONNECTION_ID_FRAME)) {
     return false;
   }
@@ -1916,9 +1926,10 @@
 
 bool QuicConnection::OnRetireConnectionIdFrame(
     const QuicRetireConnectionIdFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing RETIRE_CONNECTION_ID frame when "
-                              "connection is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_14, !connected_)
+      << "Processing RETIRE_CONNECTION_ID frame when "
+         "connection is closed. Last frame: "
+      << most_recent_frame_type_;
   if (!UpdatePacketContent(RETIRE_CONNECTION_ID_FRAME)) {
     return false;
   }
@@ -1994,9 +2005,10 @@
 }
 
 bool QuicConnection::OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing HANDSHAKE_DONE frame when connection "
-                              "is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_15, !connected_)
+      << "Processing HANDSHAKE_DONE frame when connection "
+         "is closed. Last frame: "
+      << most_recent_frame_type_;
   if (!version().UsesTls()) {
     CloseConnection(IETF_QUIC_PROTOCOL_VIOLATION,
                     "Handshake done frame is unsupported",
@@ -2026,9 +2038,10 @@
 }
 
 bool QuicConnection::OnAckFrequencyFrame(const QuicAckFrequencyFrame& frame) {
-  QUIC_BUG_IF(!connected_) << "Processing ACK_FREQUENCY frame when connection "
-                              "is closed. Last frame: "
-                           << most_recent_frame_type_;
+  QUIC_BUG_IF_V2(quic_bug_10511_16, !connected_)
+      << "Processing ACK_FREQUENCY frame when connection "
+         "is closed. Last frame: "
+      << most_recent_frame_type_;
   if (debug_visitor_ != nullptr) {
     debug_visitor_->OnAckFrequencyFrame(frame);
   }
@@ -2203,7 +2216,8 @@
                "validated.";
         path_validator_.CancelPathValidation();
       } else {
-        QUIC_BUG << "Received Stateless Reset on unknown socket.";
+        QUIC_BUG_V2(quic_bug_10511_17)
+            << "Received Stateless Reset on unknown socket.";
       }
       return;
     }
@@ -2368,7 +2382,7 @@
                                       size_t write_length,
                                       QuicStreamOffset offset) {
   if (write_length == 0) {
-    QUIC_BUG << "Attempt to send empty crypto frame";
+    QUIC_BUG_V2(quic_bug_10511_18) << "Attempt to send empty crypto frame";
     return 0;
   }
   if (level == ENCRYPTION_INITIAL) {
@@ -2389,7 +2403,7 @@
                                                 QuicStreamOffset offset,
                                                 StreamSendingState state) {
   if (state == NO_FIN && write_length == 0) {
-    QUIC_BUG << "Attempt to send empty stream frame";
+    QUIC_BUG_V2(quic_bug_10511_19) << "Attempt to send empty stream frame";
     return QuicConsumedData(0, false);
   }
 
@@ -2607,9 +2621,10 @@
         QuicLegacyVersionEncapsulator::GetMinimumOverhead(
             legacy_version_encapsulation_sni_);
     if (max_packet_length < minimum_overhead) {
-      QUIC_BUG << "Cannot apply Legacy Version Encapsulation overhead because "
-               << "max_packet_length " << max_packet_length
-               << " < minimum_overhead " << minimum_overhead;
+      QUIC_BUG_V2(quic_bug_10511_20)
+          << "Cannot apply Legacy Version Encapsulation overhead because "
+          << "max_packet_length " << max_packet_length << " < minimum_overhead "
+          << minimum_overhead;
       legacy_version_encapsulation_in_progress_ = false;
       legacy_version_encapsulation_enabled_ = false;
       MaybeUpdatePacketCreatorMaxPacketLengthAndPadding();
@@ -2678,10 +2693,10 @@
   // Ensure the time coming from the packet reader is within 2 minutes of now.
   if (std::abs((packet.receipt_time() - clock_->ApproximateNow()).ToSeconds()) >
       2 * 60) {
-    QUIC_BUG << "Packet receipt time:"
-             << packet.receipt_time().ToDebuggingValue()
-             << " too far from current time:"
-             << clock_->ApproximateNow().ToDebuggingValue();
+    QUIC_BUG_V2(quic_bug_10511_21)
+        << "Packet receipt time:" << packet.receipt_time().ToDebuggingValue()
+        << " too far from current time:"
+        << clock_->ApproximateNow().ToDebuggingValue();
   }
   time_of_last_received_packet_ = packet.receipt_time();
   QUIC_DVLOG(1) << ENDPOINT << "time of last received packet: "
@@ -2740,7 +2755,7 @@
   if (writer_->IsWriteBlocked()) {
     const std::string error_details =
         "Writer is blocked while calling OnCanWrite.";
-    QUIC_BUG << ENDPOINT << error_details;
+    QUIC_BUG_V2(quic_bug_10511_22) << ENDPOINT << error_details;
     CloseConnection(QUIC_INTERNAL_ERROR, error_details,
                     ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
     return;
@@ -3155,8 +3170,9 @@
 bool QuicConnection::WritePacket(SerializedPacket* packet) {
   if (sent_packet_manager_.GetLargestSentPacket().IsInitialized() &&
       packet->packet_number < sent_packet_manager_.GetLargestSentPacket()) {
-    QUIC_BUG << "Attempt to write packet:" << packet->packet_number
-             << " after:" << sent_packet_manager_.GetLargestSentPacket();
+    QUIC_BUG_V2(quic_bug_10511_23)
+        << "Attempt to write packet:" << packet->packet_number
+        << " after:" << sent_packet_manager_.GetLargestSentPacket();
     CloseConnection(QUIC_INTERNAL_ERROR, "Packet written out of order.",
                     ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
     return true;
@@ -3310,10 +3326,10 @@
             << quiche::QuicheTextUtils::HexDump(absl::string_view(
                    packet->encrypted_buffer, encrypted_length));
       } else {
-        QUIC_BUG << ENDPOINT
-                 << "Failed to perform Legacy Version Encapsulation on "
-                 << packet->encryption_level << " packet number "
-                 << packet_number << " of length " << encrypted_length;
+        QUIC_BUG_V2(quic_bug_10511_24)
+            << ENDPOINT << "Failed to perform Legacy Version Encapsulation on "
+            << packet->encryption_level << " packet number " << packet_number
+            << " of length " << encrypted_length;
       }
       if (!buffered_packets_.empty() || HandleWriteBlocked()) {
         // Buffer the packet.
@@ -3455,7 +3471,8 @@
 
   if (debug_visitor_ != nullptr) {
     if (sent_packet_manager_.unacked_packets().empty()) {
-      QUIC_BUG << "Unacked map is empty right after packet is sent";
+      QUIC_BUG_V2(quic_bug_10511_25)
+          << "Unacked map is empty right after packet is sent";
     } else {
       debug_visitor_->OnPacketSent(
           packet->packet_number, packet->encrypted_length,
@@ -3517,8 +3534,9 @@
     return false;
   }
   if (!lowest_packet_sent_in_current_key_phase_.IsInitialized()) {
-    QUIC_BUG << "lowest_packet_sent_in_current_key_phase_ must be initialized "
-                "before calling MaybeHandleAeadConfidentialityLimits";
+    QUIC_BUG_V2(quic_bug_10511_26)
+        << "lowest_packet_sent_in_current_key_phase_ must be initialized "
+           "before calling MaybeHandleAeadConfidentialityLimits";
     return false;
   }
 
@@ -3531,7 +3549,7 @@
         absl::StrCat("packet_number(", packet.packet_number.ToString(),
                      ") < lowest_packet_sent_in_current_key_phase_ (",
                      lowest_packet_sent_in_current_key_phase_.ToString(), ")");
-    QUIC_BUG << error_details;
+    QUIC_BUG_V2(quic_bug_10511_27) << error_details;
     CloseConnection(QUIC_INTERNAL_ERROR, error_details,
                     ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
     return true;
@@ -4107,7 +4125,7 @@
 bool QuicConnection::InitiateKeyUpdate(KeyUpdateReason reason) {
   QUIC_DLOG(INFO) << ENDPOINT << "InitiateKeyUpdate";
   if (!IsKeyUpdateAllowed()) {
-    QUIC_BUG << "key update not allowed";
+    QUIC_BUG_V2(quic_bug_10511_28) << "key update not allowed";
     return false;
   }
   return framer_.DoKeyUpdate(reason);
@@ -4531,7 +4549,8 @@
 void QuicConnection::SetRetransmissionAlarm() {
   if (!connected_) {
     if (retransmission_alarm_->IsSet()) {
-      QUIC_BUG << ENDPOINT << "Retransmission alarm is set while disconnected";
+      QUIC_BUG_V2(quic_bug_10511_29)
+          << ENDPOINT << "Retransmission alarm is set while disconnected";
       retransmission_alarm_->Cancel();
     }
     return;
@@ -4728,7 +4747,8 @@
 QuicByteCount QuicConnection::GetLimitedMaxPacketSize(
     QuicByteCount suggested_max_packet_size) {
   if (!peer_address().IsInitialized()) {
-    QUIC_BUG << "Attempted to use a connection without a valid peer address";
+    QUIC_BUG_V2(quic_bug_10511_30)
+        << "Attempted to use a connection without a valid peer address";
     return suggested_max_packet_size;
   }
 
@@ -4777,8 +4797,9 @@
     bool is_response) {
   QUICHE_DCHECK(peer_address.IsInitialized());
   if (!connected_) {
-    QUIC_BUG << "Not sending connectivity probing packet as connection is "
-             << "disconnected.";
+    QUIC_BUG_V2(quic_bug_10511_31)
+        << "Not sending connectivity probing packet as connection is "
+        << "disconnected.";
     return false;
   }
   if (perspective_ == Perspective::IS_SERVER && probing_writer == nullptr) {
@@ -4874,7 +4895,8 @@
 
   if (debug_visitor_ != nullptr) {
     if (sent_packet_manager_.unacked_packets().empty()) {
-      QUIC_BUG << "Unacked map is empty right after packet is sent";
+      QUIC_BUG_V2(quic_bug_10511_32)
+          << "Unacked map is empty right after packet is sent";
     } else {
       debug_visitor_->OnPacketSent(
           packet->packet_number, packet->encrypted_length,
@@ -4921,7 +4943,7 @@
 
 void QuicConnection::OnEffectivePeerMigrationValidated() {
   if (active_effective_peer_migration_type_ == NO_CHANGE) {
-    QUIC_BUG << "No migration underway.";
+    QUIC_BUG_V2(quic_bug_10511_33) << "No migration underway.";
     return;
   }
   highest_packet_sent_before_effective_peer_migration_.Clear();
@@ -4938,7 +4960,8 @@
       debug_visitor_->OnPeerMigrationValidated(
           now - stats_.handshake_completion_time);
     } else {
-      QUIC_BUG << "Handshake completion time is larger than current time.";
+      QUIC_BUG_V2(quic_bug_10511_34)
+          << "Handshake completion time is larger than current time.";
     }
   }
 
@@ -4956,7 +4979,8 @@
   // determine whether |type| is allowed.
   if (!validate_client_addresses_) {
     if (type == NO_CHANGE) {
-      QUIC_BUG << "EffectivePeerMigration started without address change.";
+      QUIC_BUG_V2(quic_bug_10511_35)
+          << "EffectivePeerMigration started without address change.";
       return;
     }
     QUIC_DLOG(INFO) << ENDPOINT << "Effective peer's ip:port changed from "
@@ -4976,7 +5000,8 @@
 
   if (type == NO_CHANGE) {
     UpdatePeerAddress(last_packet_source_address_);
-    QUIC_BUG << "EffectivePeerMigration started without address change.";
+    QUIC_BUG_V2(quic_bug_10511_36)
+        << "EffectivePeerMigration started without address change.";
     return;
   }
 
@@ -5199,8 +5224,9 @@
   }
 
   if (probing_retransmission_pending_) {
-    QUIC_BUG << "MaybeSendProbingRetransmissions is called while another call "
-                "to it is already in progress";
+    QUIC_BUG_V2(quic_bug_10511_37)
+        << "MaybeSendProbingRetransmissions is called while another call "
+           "to it is already in progress";
     return;
   }
 
@@ -5470,8 +5496,8 @@
                                           QuicMemSliceSpan message,
                                           bool flush) {
   if (!VersionSupportsMessageFrames(transport_version())) {
-    QUIC_BUG << "MESSAGE frame is not supported for version "
-             << transport_version();
+    QUIC_BUG_V2(quic_bug_10511_38)
+        << "MESSAGE frame is not supported for version " << transport_version();
     return MESSAGE_STATUS_UNSUPPORTED;
   }
   if (message.total_length() > GetCurrentLargestMessagePayload()) {
@@ -5550,9 +5576,10 @@
   }
 
   if (!framer_.HasAnEncrypterForSpace(space)) {
-    QUIC_BUG << ENDPOINT
-             << "Try to bundle crypto with ACK with missing key of space "
-             << PacketNumberSpaceToString(space);
+    QUIC_BUG_V2(quic_bug_10511_39)
+        << ENDPOINT
+        << "Try to bundle crypto with ACK with missing key of space "
+        << PacketNumberSpaceToString(space);
     return;
   }
 
@@ -5701,9 +5728,10 @@
       !framer_.HasEncrypterOfEncryptionLevel(ENCRYPTION_INITIAL)) {
     // Initial packet will be re-serialized. Neuter it in case initial key has
     // been dropped.
-    QUIC_BUG << ENDPOINT
-             << "Coalescer contains initial packet while initial key has "
-                "been dropped.";
+    QUIC_BUG_V2(quic_bug_10511_40)
+        << ENDPOINT
+        << "Coalescer contains initial packet while initial key has "
+           "been dropped.";
     coalesced_packet_.NeuterInitialPacket();
   }
   if (coalesced_packet_.length() == 0) {
@@ -5957,9 +5985,10 @@
 void QuicConnection::OnBlackholeDetected() {
   if (default_enable_5rto_blackhole_detection_ &&
       !sent_packet_manager_.HasInFlightPackets()) {
-    QUIC_BUG << ENDPOINT
-             << "Blackhole detected, but there is no bytes in flight, version: "
-             << version();
+    QUIC_BUG_V2(quic_bug_10511_41)
+        << ENDPOINT
+        << "Blackhole detected, but there is no bytes in flight, version: "
+        << version();
     // Do not close connection if there is no bytes in flight.
     return;
   }
@@ -6512,7 +6541,8 @@
         alternative_path_.send_algorithm.release());
     sent_packet_manager_.SetRttStats(alternative_path_.rtt_stats.value());
   } else {
-    QUIC_BUG << "Fail to store congestion controller before migration.";
+    QUIC_BUG_V2(quic_bug_10511_42)
+        << "Fail to store congestion controller before migration.";
   }
 
   UpdatePeerAddress(original_direct_peer_address);
diff --git a/quic/core/quic_control_frame_manager.cc b/quic/core/quic_control_frame_manager.cc
index 64e5f5d..aedd365 100644
--- a/quic/core/quic_control_frame_manager.cc
+++ b/quic/core/quic_control_frame_manager.cc
@@ -180,8 +180,9 @@
     return;
   }
   if (id > least_unsent_) {
-    QUIC_BUG << "Try to send control frames out of order, id: " << id
-             << " least_unsent: " << least_unsent_;
+    QUIC_BUG_V2(quic_bug_10517_1)
+        << "Try to send control frames out of order, id: " << id
+        << " least_unsent: " << least_unsent_;
     delegate_->OnControlFrameManagerError(
         QUIC_INTERNAL_ERROR, "Try to send control frames out of order");
     return;
@@ -211,7 +212,7 @@
     return;
   }
   if (id >= least_unsent_) {
-    QUIC_BUG << "Try to mark unsent control frame as lost";
+    QUIC_BUG_V2(quic_bug_10517_2) << "Try to mark unsent control frame as lost";
     delegate_->OnControlFrameManagerError(
         QUIC_INTERNAL_ERROR, "Try to mark unsent control frame as lost");
     return;
@@ -279,7 +280,7 @@
     return true;
   }
   if (id >= least_unsent_) {
-    QUIC_BUG << "Try to retransmit unsent control frame";
+    QUIC_BUG_V2(quic_bug_10517_3) << "Try to retransmit unsent control frame";
     delegate_->OnControlFrameManagerError(
         QUIC_INTERNAL_ERROR, "Try to retransmit unsent control frame");
     return false;
@@ -333,7 +334,7 @@
     return false;
   }
   if (id >= least_unsent_) {
-    QUIC_BUG << "Try to ack unsent control frame";
+    QUIC_BUG_V2(quic_bug_10517_4) << "Try to ack unsent control frame";
     delegate_->OnControlFrameManagerError(QUIC_INTERNAL_ERROR,
                                           "Try to ack unsent control frame");
     return false;
diff --git a/quic/core/quic_crypto_client_stream.cc b/quic/core/quic_crypto_client_stream.cc
index 3160f58..dfa5b86 100644
--- a/quic/core/quic_crypto_client_stream.cc
+++ b/quic/core/quic_crypto_client_stream.cc
@@ -49,8 +49,9 @@
           proof_handler, has_application_state);
       break;
     case PROTOCOL_UNSUPPORTED:
-      QUIC_BUG << "Attempting to create QuicCryptoClientStream for unknown "
-                  "handshake protocol";
+      QUIC_BUG_V2(quic_bug_10296_1)
+          << "Attempting to create QuicCryptoClientStream for unknown "
+             "handshake protocol";
   }
 }
 
diff --git a/quic/core/quic_crypto_server_stream_base.cc b/quic/core/quic_crypto_server_stream_base.cc
index b80d06d..368f47b 100644
--- a/quic/core/quic_crypto_server_stream_base.cc
+++ b/quic/core/quic_crypto_server_stream_base.cc
@@ -42,9 +42,9 @@
     case PROTOCOL_UNSUPPORTED:
       break;
   }
-  QUIC_BUG << "Unknown handshake protocol: "
-           << static_cast<int>(
-                  session->connection()->version().handshake_protocol);
+  QUIC_BUG_V2(quic_bug_10492_1)
+      << "Unknown handshake protocol: "
+      << static_cast<int>(session->connection()->version().handshake_protocol);
   return nullptr;
 }
 
diff --git a/quic/core/quic_crypto_stream.cc b/quic/core/quic_crypto_stream.cc
index 1b2f6db..ad5ad11 100644
--- a/quic/core/quic_crypto_stream.cc
+++ b/quic/core/quic_crypto_stream.cc
@@ -155,7 +155,7 @@
     return;
   }
   if (data.empty()) {
-    QUIC_BUG << "Empty crypto data being written";
+    QUIC_BUG_V2(quic_bug_10322_1) << "Empty crypto data being written";
     return;
   }
   const bool had_buffered_data = HasBufferedCryptoFrames();
@@ -166,7 +166,7 @@
   send_buffer->SaveStreamData(&iov, /*iov_count=*/1, /*iov_offset=*/0,
                               data.length());
   if (kMaxStreamLength - offset < data.length()) {
-    QUIC_BUG << "Writing too much crypto handshake data";
+    QUIC_BUG_V2(quic_bug_10322_2) << "Writing too much crypto handshake data";
     // TODO(nharper): Switch this to an IETF QUIC error code, possibly
     // INTERNAL_ERROR?
     OnUnrecoverableError(QUIC_STREAM_LENGTH_OVERFLOW,
@@ -231,7 +231,8 @@
 
 void QuicCryptoStream::OnStreamDataConsumed(QuicByteCount bytes_consumed) {
   if (QuicVersionUsesCryptoFrames(session()->transport_version())) {
-    QUIC_BUG << "Stream data consumed when CRYPTO frames should be in use";
+    QUIC_BUG_V2(quic_bug_10322_3)
+        << "Stream data consumed when CRYPTO frames should be in use";
   }
   if (bytes_consumed > 0) {
     bytes_consumed_[session()->connection()->encryption_level()].Add(