Skip to content

Commit

Permalink
chore(exchanger): add round trip duration to error message
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Nov 3, 2024
1 parent 5326983 commit bc6f5ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/exchanger/exchanger.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ func (e *Exchanger) Exchange(ctx context.Context, network string, request *dns.M
}
dnsConn := &dns.Conn{Conn: netConn}

response, _, err = e.client.ExchangeWithConnContext(ctx, request, dnsConn)
response, roundTripDuration, err := e.client.ExchangeWithConnContext(ctx, request, dnsConn)

closeErr := dnsConn.Close()
if closeErr != nil {
e.warner.Warn("cannot close " + e.dialer.String() + " connection: " + closeErr.Error())
}

if err != nil {
return nil, fmt.Errorf("exchanging over %s connection for request %s: %w",
e.dialer, extractRequestQuestion(request), err)
return nil, fmt.Errorf("exchanging over %s connection (%s) for request %s: %w",
e.dialer, roundTripDuration, extractRequestQuestion(request), err)
}

return response, nil
Expand Down

0 comments on commit bc6f5ac

Please sign in to comment.