diff --git a/net/dns/resolver/forwarder.go b/net/dns/resolver/forwarder.go index 4a0bbc7fc..16c08a5ca 100644 --- a/net/dns/resolver/forwarder.go +++ b/net/dns/resolver/forwarder.go @@ -460,6 +460,10 @@ func (f *forwarder) sendDoH(ctx context.Context, urlBase string, c *http.Client, var ( verboseDNSForward = envknob.RegisterBool("TS_DEBUG_DNS_FORWARD_SEND") skipTCPRetry = envknob.RegisterBool("TS_DNS_FORWARD_SKIP_TCP_RETRY") + + // For correlating log messages in the send() function; only used when + // verboseDNSForward() is true. + forwarderCount atomic.Uint64 ) // send sends packet to dst. It is best effort. @@ -467,9 +471,10 @@ var ( // send expects the reply to have the same txid as txidOut. func (f *forwarder) send(ctx context.Context, fq *forwardQuery, rr resolverAndDelay) (ret []byte, err error) { if verboseDNSForward() { - f.logf("forwarder.send(%q) ...", rr.name.Addr) + id := forwarderCount.Add(1) + f.logf("forwarder.send(%q) [%d] ...", rr.name.Addr, id) defer func() { - f.logf("forwarder.send(%q) = %v, %v", rr.name.Addr, len(ret), err) + f.logf("forwarder.send(%q) [%d] = %v, %v", rr.name.Addr, id, len(ret), err) }() } if strings.HasPrefix(rr.name.Addr, "http://") {