Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
936b483a
Commit
936b483a
authored
Jul 14, 2021
by
Ondřej Benkovský
Committed by
GitHub
Jul 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
publish trace id as metadata from trace plugin (#4749)
Signed-off-by:
Ondrej Benkovsky
<
ondrej.benkovsky@wandera.com
>
parent
e62600a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
plugin/trace/README.md
plugin/trace/README.md
+7
-0
plugin/trace/trace.go
plugin/trace/trace.go
+10
-0
No files found.
plugin/trace/README.md
View file @
936b483a
...
@@ -93,6 +93,13 @@ trace tracinghost:9411 {
...
@@ -93,6 +93,13 @@ trace tracinghost:9411 {
}
}
~~~
~~~
## Metadata
The trace plugin will publish the following metadata, if the
*metadata*
plugin is also enabled:
*
`trace/traceid`
: identifier of (zipkin/datadog) trace of processed request
## See Also
## See Also
See the
*debug*
plugin for more information about debug logging.
See the
*debug*
plugin for more information about debug logging.
plugin/trace/trace.go
View file @
936b483a
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"sync/atomic"
"sync/atomic"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/metadata"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/plugin/pkg/rcode"
"github.com/coredns/coredns/plugin/pkg/rcode"
...
@@ -21,6 +22,7 @@ import (
...
@@ -21,6 +22,7 @@ import (
zipkinot
"github.com/openzipkin-contrib/zipkin-go-opentracing"
zipkinot
"github.com/openzipkin-contrib/zipkin-go-opentracing"
"github.com/openzipkin/zipkin-go"
"github.com/openzipkin/zipkin-go"
zipkinhttp
"github.com/openzipkin/zipkin-go/reporter/http"
zipkinhttp
"github.com/openzipkin/zipkin-go/reporter/http"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentracer"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentracer"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
...
@@ -28,6 +30,7 @@ import (
...
@@ -28,6 +30,7 @@ import (
const
(
const
(
defaultTopLevelSpanName
=
"servedns"
defaultTopLevelSpanName
=
"servedns"
metaTraceIdKey
=
"trace/traceid"
)
)
type
traceTags
struct
{
type
traceTags
struct
{
...
@@ -141,6 +144,13 @@ func (t *trace) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
...
@@ -141,6 +144,13 @@ func (t *trace) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
span
=
t
.
Tracer
()
.
StartSpan
(
defaultTopLevelSpanName
)
span
=
t
.
Tracer
()
.
StartSpan
(
defaultTopLevelSpanName
)
defer
span
.
Finish
()
defer
span
.
Finish
()
switch
spanCtx
:=
span
.
Context
()
.
(
type
)
{
case
zipkinot
.
SpanContext
:
metadata
.
SetValueFunc
(
ctx
,
metaTraceIdKey
,
func
()
string
{
return
spanCtx
.
TraceID
.
String
()
})
case
ddtrace
.
SpanContext
:
metadata
.
SetValueFunc
(
ctx
,
metaTraceIdKey
,
func
()
string
{
return
fmt
.
Sprint
(
spanCtx
.
TraceID
())
})
}
rw
:=
dnstest
.
NewRecorder
(
w
)
rw
:=
dnstest
.
NewRecorder
(
w
)
ctx
=
ot
.
ContextWithSpan
(
ctx
,
span
)
ctx
=
ot
.
ContextWithSpan
(
ctx
,
span
)
status
,
err
:=
plugin
.
NextOrFailure
(
t
.
Name
(),
t
.
Next
,
ctx
,
rw
,
r
)
status
,
err
:=
plugin
.
NextOrFailure
(
t
.
Name
(),
t
.
Next
,
ctx
,
rw
,
r
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment