Skip to content

Commit

Permalink
fixup! add span per connection attempt
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Benkovsky <ondrej.benkovsky@wandera.com>
  • Loading branch information
Ondrej Benkovsky committed Jul 16, 2021
1 parent 8edc9b4 commit 46a845a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ func (c *client) Endpoint() string {
func (c *client) Request(ctx context.Context, r *request.Request) (*dns.Msg, error) {
span := ot.SpanFromContext(ctx)
if span != nil {
childSpan := span.Tracer().StartSpan("connect", ot.ChildOf(span.Context()))
childSpan := span.Tracer().StartSpan("request", ot.ChildOf(span.Context()))
otext.PeerAddress.Set(childSpan, c.addr)
ctx = ot.ContextWithSpan(ctx, childSpan)
defer childSpan.Finish()
}
start := time.Now()
Expand Down
7 changes: 7 additions & 0 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net"

"github.com/miekg/dns"
ot "github.com/opentracing/opentracing-go"
)

// Transport represent a solution to connect to remote DNS endpoint with specific network
Expand Down Expand Up @@ -59,6 +60,12 @@ func (t *transportImpl) Dial(ctx context.Context, network string) (*dns.Conn, er
}

func (t *transportImpl) dial(ctx context.Context, c *dns.Client) (*dns.Conn, error) {
span := ot.SpanFromContext(ctx)
if span != nil {
childSpan := span.Tracer().StartSpan("connect", ot.ChildOf(span.Context()))
ctx = ot.ContextWithSpan(ctx, childSpan)
defer childSpan.Finish()
}
var d net.Dialer
if c.Dialer == nil {
d = net.Dialer{Timeout: maxTimeout}
Expand Down

0 comments on commit 46a845a

Please sign in to comment.