aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/dnsserver/config.go17
-rw-r--r--plugin/trace/setup.go3
-rw-r--r--plugin/trace/trace.go11
3 files changed, 7 insertions, 24 deletions
diff --git a/core/dnsserver/config.go b/core/dnsserver/config.go
index d21a52380..a63058d43 100644
--- a/core/dnsserver/config.go
+++ b/core/dnsserver/config.go
@@ -3,7 +3,6 @@ package dnsserver
import (
"crypto/tls"
"fmt"
- "net"
"github.com/coredns/coredns/plugin"
@@ -53,22 +52,6 @@ type Config struct {
registry map[string]plugin.Handler
}
-//HostAddresses builds a representation of the addresses of this Config
-//after server is started ONLY, can be used as a Key for identifing that config
-// :53 or 127.0.0.1:53 or 127.0.0.1:53/::1:53
-func (c *Config) HostAddresses() string {
- all := ""
- for _, h := range c.ListenHosts {
- addr := net.JoinHostPort(h, c.Port)
- if all == "" {
- all = addr
- continue
- }
- all = all + "/" + addr
- }
- return all
-}
-
// keyForConfig build a key for identifying the configs during setup time
func keyForConfig(blocIndex int, blocKeyIndex int) string {
return fmt.Sprintf("%d:%d", blocIndex, blocKeyIndex)
diff --git a/plugin/trace/setup.go b/plugin/trace/setup.go
index 881ddc357..1614cc177 100644
--- a/plugin/trace/setup.go
+++ b/plugin/trace/setup.go
@@ -41,7 +41,8 @@ func traceParse(c *caddy.Controller) (*trace, error) {
)
cfg := dnsserver.GetConfig(c)
- tr.ServiceEndpoint = cfg.HostAddresses()
+ tr.serviceEndpoint = cfg.ListenHosts[0] + ":" + cfg.Port
+
for c.Next() { // trace
var err error
args := c.RemainingArgs()
diff --git a/plugin/trace/trace.go b/plugin/trace/trace.go
index 93b8e4989..a0a2071ea 100644
--- a/plugin/trace/trace.go
+++ b/plugin/trace/trace.go
@@ -9,6 +9,7 @@ import (
"sync/atomic"
"github.com/coredns/coredns/plugin"
+ "github.com/coredns/coredns/plugin/metrics"
// Plugin the trace package.
_ "github.com/coredns/coredns/plugin/pkg/trace"
@@ -20,10 +21,10 @@ import (
type trace struct {
Next plugin.Handler
- ServiceEndpoint string
Endpoint string
EndpointType string
tracer ot.Tracer
+ serviceEndpoint string
serviceName string
clientServer bool
every uint64
@@ -58,7 +59,7 @@ func (t *trace) setupZipkin() error {
return err
}
- recorder := zipkin.NewRecorder(collector, false, t.ServiceEndpoint, t.serviceName)
+ recorder := zipkin.NewRecorder(collector, false, t.serviceEndpoint, t.serviceName)
t.tracer, err = zipkin.NewTracer(recorder, zipkin.ClientServerSameSpan(t.clientServer))
return err
@@ -81,9 +82,7 @@ func (t *trace) setupDatadog() error {
}
// Name implements the Handler interface.
-func (t *trace) Name() string {
- return "trace"
-}
+func (t *trace) Name() string { return "trace" }
// ServeDNS implements the plugin.Handle interface.
func (t *trace) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
@@ -96,7 +95,7 @@ func (t *trace) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
}
}
if span := ot.SpanFromContext(ctx); span == nil && trace {
- span := t.Tracer().StartSpan("servedns")
+ span := t.Tracer().StartSpan("servedns:" + metrics.WithServer(ctx))
defer span.Finish()
ctx = ot.ContextWithSpan(ctx, span)
}