mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
plugin/trace: make zipkin and datadog reporters log errors using CoreDNS logger (#5452)
This commit is contained in:
@@ -4,6 +4,7 @@ package trace
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
stdlog "log"
|
||||
"net/http"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -12,7 +13,7 @@ import (
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/metadata"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnstest"
|
||||
"github.com/coredns/coredns/plugin/pkg/log"
|
||||
clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
"github.com/coredns/coredns/plugin/pkg/rcode"
|
||||
_ "github.com/coredns/coredns/plugin/pkg/trace" // Plugin the trace package.
|
||||
"github.com/coredns/coredns/request"
|
||||
@@ -35,6 +36,8 @@ const (
|
||||
metaTraceIdKey = "trace/traceid"
|
||||
)
|
||||
|
||||
var log = clog.NewWithPlugin("trace")
|
||||
|
||||
type traceTags struct {
|
||||
Name string
|
||||
Type string
|
||||
@@ -90,10 +93,11 @@ func (t *trace) OnStartup() error {
|
||||
case "datadog":
|
||||
tracer := opentracer.New(
|
||||
tracer.WithAgentAddr(t.Endpoint),
|
||||
tracer.WithDebugMode(log.D.Value()),
|
||||
tracer.WithDebugMode(clog.D.Value()),
|
||||
tracer.WithGlobalTag(ext.SpanTypeDNS, true),
|
||||
tracer.WithServiceName(t.serviceName),
|
||||
tracer.WithAnalyticsRate(t.datadogAnalyticsRate),
|
||||
tracer.WithLogger(&loggerAdapter{log}),
|
||||
)
|
||||
t.tracer = tracer
|
||||
t.tagSet = tagByProvider["datadog"]
|
||||
@@ -105,7 +109,8 @@ func (t *trace) OnStartup() error {
|
||||
}
|
||||
|
||||
func (t *trace) setupZipkin() error {
|
||||
reporter := zipkinhttp.NewReporter(t.Endpoint)
|
||||
logOpt := zipkinhttp.Logger(stdlog.New(&loggerAdapter{log}, "", 0))
|
||||
reporter := zipkinhttp.NewReporter(t.Endpoint, logOpt)
|
||||
recorder, err := zipkin.NewEndpoint(t.serviceName, t.serviceEndpoint)
|
||||
if err != nil {
|
||||
log.Warningf("build Zipkin endpoint found err: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user