feat: collect system resolver results using context (#856)
* feat: Introduce context-based tracing to the system resolver * testing: added tests for context-based tracing in netxlite resolvers * Apply suggestions from code review Reference issue: https://github.com/ooni/probe/issues/2207 Co-authored-by: decfox <decfox@github.com> Co-authored-by: Simone Basso <bassosimone@gmail.com>
This commit is contained in:
parent
a818373e2c
commit
576b52b1e3
3 changed files with 347 additions and 2 deletions
|
|
@ -130,11 +130,17 @@ var _ model.Resolver = &resolverSystem{}
|
|||
func (r *resolverSystem) LookupHost(ctx context.Context, hostname string) ([]string, error) {
|
||||
encoder := &DNSEncoderMiekg{}
|
||||
query := encoder.Encode(hostname, dns.TypeANY, false)
|
||||
trace := ContextTraceOrDefault(ctx)
|
||||
start := trace.TimeNow()
|
||||
resp, err := r.t.RoundTrip(ctx, query)
|
||||
end := trace.TimeNow()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
trace.OnDNSRoundTripForLookupHost(start, r, query, resp, []string{}, err, end)
|
||||
return []string{}, err
|
||||
}
|
||||
return resp.DecodeLookupHost()
|
||||
addrs, err := resp.DecodeLookupHost()
|
||||
trace.OnDNSRoundTripForLookupHost(start, r, query, resp, addrs, err, end)
|
||||
return addrs, err
|
||||
}
|
||||
|
||||
func (r *resolverSystem) Network() string {
|
||||
|
|
|
|||
Loading…
Reference in a new issue