mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
@@ -4,7 +4,6 @@ package trace
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
@@ -12,6 +11,9 @@ import (
|
||||
"github.com/coredns/coredns/plugin/metrics"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnstest"
|
||||
"github.com/coredns/coredns/plugin/pkg/rcode"
|
||||
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentracer"
|
||||
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
|
||||
|
||||
// Plugin the trace package.
|
||||
_ "github.com/coredns/coredns/plugin/pkg/trace"
|
||||
"github.com/coredns/coredns/request"
|
||||
@@ -19,7 +21,6 @@ import (
|
||||
"github.com/miekg/dns"
|
||||
ot "github.com/opentracing/opentracing-go"
|
||||
zipkin "github.com/openzipkin/zipkin-go-opentracing"
|
||||
ddtrace "gopkg.in/DataDog/dd-trace-go.v0/opentracing"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -53,7 +54,7 @@ func (t *trace) OnStartup() error {
|
||||
case "zipkin":
|
||||
err = t.setupZipkin()
|
||||
case "datadog":
|
||||
err = t.setupDatadog()
|
||||
t.setupDatadog()
|
||||
default:
|
||||
err = fmt.Errorf("unknown endpoint type: %s", t.EndpointType)
|
||||
}
|
||||
@@ -74,20 +75,9 @@ 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)
|
||||
func (t *trace) setupDatadog() {
|
||||
tracer := opentracer.New(tracer.WithAgentAddr(t.Endpoint), tracer.WithServiceName(t.serviceName), tracer.WithDebugMode(true))
|
||||
t.tracer = tracer
|
||||
return err
|
||||
}
|
||||
|
||||
// Name implements the Handler interface.
|
||||
|
||||
Reference in New Issue
Block a user