Skip to content

Commit

Permalink
Merge pull request #36 from Tantalor93/span
Browse files Browse the repository at this point in the history
add span per connection attempt
  • Loading branch information
denis-tingaikin authored Jul 17, 2021
2 parents 42cacc5 + 46a845a commit 1892892
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 91 deletions.
9 changes: 9 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (

"github.com/coredns/coredns/request"
"github.com/miekg/dns"
ot "github.com/opentracing/opentracing-go"
otext "github.com/opentracing/opentracing-go/ext"
)

// Client represents the proxy for remote DNS server
Expand Down Expand Up @@ -64,6 +66,13 @@ func (c *client) Endpoint() string {

// Request sends request to DNS server
func (c *client) Request(ctx context.Context, r *request.Request) (*dns.Msg, error) {
span := ot.SpanFromContext(ctx)
if span != nil {
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()
conn, err := c.transport.Dial(ctx, c.net)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/coredns/coredns v1.8.0
github.com/dnstap/golang-dnstap v0.2.2
github.com/miekg/dns v1.1.34
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.8.0
github.com/stretchr/testify v1.5.1
Expand Down
Loading

0 comments on commit 1892892

Please sign in to comment.