mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
Add DD support (#1596)
This commit is contained in:
committed by
John Belamaric
parent
95342dfaad
commit
87790dd47c
@@ -3,6 +3,7 @@ package trace
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
// Plugin the trace package.
|
||||
_ "github.com/coredns/coredns/plugin/pkg/trace"
|
||||
|
||||
ddtrace "github.com/DataDog/dd-trace-go/opentracing"
|
||||
"github.com/miekg/dns"
|
||||
ot "github.com/opentracing/opentracing-go"
|
||||
zipkin "github.com/openzipkin/zipkin-go-opentracing"
|
||||
@@ -40,6 +42,8 @@ func (t *trace) OnStartup() error {
|
||||
switch t.EndpointType {
|
||||
case "zipkin":
|
||||
err = t.setupZipkin()
|
||||
case "datadog":
|
||||
err = t.setupDatadog()
|
||||
default:
|
||||
err = fmt.Errorf("unknown endpoint type: %s", t.EndpointType)
|
||||
}
|
||||
@@ -60,6 +64,22 @@ func (t *trace) setupZipkin() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *trace) setupDatadog() error {
|
||||
config := ddtrace.NewConfiguration()
|
||||
config.ServiceName = t.serviceName
|
||||
|
||||
host := strings.Split(t.Endpoint, ":")
|
||||
config.AgentHostname = host[0]
|
||||
|
||||
if len(host) == 2 {
|
||||
config.AgentPort = host[1]
|
||||
}
|
||||
|
||||
tracer, _, err := ddtrace.NewTracer(config)
|
||||
t.tracer = tracer
|
||||
return err
|
||||
}
|
||||
|
||||
// Name implements the Handler interface.
|
||||
func (t *trace) Name() string {
|
||||
return "trace"
|
||||
|
||||
Reference in New Issue
Block a user