Add DD support (#1596)

This commit is contained in:
Yamil Asusta
2018-03-09 16:08:57 -04:00
committed by John Belamaric
parent 95342dfaad
commit 87790dd47c
214 changed files with 69817 additions and 18 deletions

View File

@@ -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"