core: remove HostAddresses() (#1728)

* core: remove HostAddresses()

config.HostAddresses() is a weird function that gathers
some data from the server and returns a string.

It is *only* used the trace plugin, to figure out what
server starts the trace.

Looks to be better to fit in the with metrics.WithServer label
on the trace itself to show which server handled the trace.

Remove HostAddresses() and cleanup trace a small bit.:w

* lint
This commit is contained in:
Miek Gieben
2018-04-25 15:27:25 +01:00
committed by GitHub
parent 7a507e34ca
commit d3f2d4a291
3 changed files with 7 additions and 24 deletions

View File

@@ -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)
}