plugin/trace: read trace context info from headers for DOH (#5439)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
This commit is contained in:
parent
1290427645
commit
af4d84d915
3 changed files with 54 additions and 1 deletions
|
@ -4,9 +4,11 @@ package trace
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/coredns/coredns/core/dnsserver"
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/metadata"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnstest"
|
||||
|
@ -140,8 +142,15 @@ func (t *trace) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
|||
return plugin.NextOrFailure(t.Name(), t.Next, ctx, w, r)
|
||||
}
|
||||
|
||||
var spanCtx ot.SpanContext
|
||||
if val := ctx.Value(dnsserver.HTTPRequestKey{}); val != nil {
|
||||
if httpReq, ok := val.(*http.Request); ok {
|
||||
spanCtx, _ = t.Tracer().Extract(ot.HTTPHeaders, ot.HTTPHeadersCarrier(httpReq.Header))
|
||||
}
|
||||
}
|
||||
|
||||
req := request.Request{W: w, Req: r}
|
||||
span = t.Tracer().StartSpan(defaultTopLevelSpanName)
|
||||
span = t.Tracer().StartSpan(defaultTopLevelSpanName, otext.RPCServerOption(spanCtx))
|
||||
defer span.Finish()
|
||||
|
||||
switch spanCtx := span.Context().(type) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue