net/dns/resolver: add ID to verbose logs in forwarder

To make it easier to correlate the starting/ending log messages.

Updates #cleanup

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I2802d53ad98e19bc8914bc58f8c04d4443227b26
pull/10765/head
Andrew Dunham 11 months ago
parent dbe70962b1
commit 35c303227a

@ -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://") {

Loading…
Cancel
Save