mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 18:53:43 -04:00
Fix go fmt, go lint, and go vet issues (#494)
This fix fixes several `go fmt`, `go lint`, and `go vet` issues, to make goreportcard happy: https://goreportcard.com/report/github.com/miekg/coredns Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -38,7 +38,7 @@ func setup(c *caddy.Controller) error {
|
||||
|
||||
func traceParse(c *caddy.Controller) (*Trace, error) {
|
||||
var (
|
||||
tr = &Trace{Endpoint: defEP, EndpointType: defEpType}
|
||||
tr = &Trace{Endpoint: defEP, EndpointType: defEpType}
|
||||
err error
|
||||
)
|
||||
|
||||
@@ -82,6 +82,6 @@ func normalizeEndpoint(epType, ep string) (string, error) {
|
||||
var traceOnce sync.Once
|
||||
|
||||
const (
|
||||
defEP = "localhost:9411"
|
||||
defEP = "localhost:9411"
|
||||
defEpType = "zipkin"
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@ func TestTraceParse(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
shouldErr bool
|
||||
endpoint string
|
||||
endpoint string
|
||||
}{
|
||||
// oks
|
||||
{`trace`, false, "http://localhost:9411/api/v1/spans"},
|
||||
|
||||
@@ -5,22 +5,22 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/miekg/coredns/middleware"
|
||||
"github.com/miekg/dns"
|
||||
ot "github.com/opentracing/opentracing-go"
|
||||
zipkin "github.com/openzipkin/zipkin-go-opentracing"
|
||||
"github.com/miekg/dns"
|
||||
ot "github.com/opentracing/opentracing-go"
|
||||
zipkin "github.com/openzipkin/zipkin-go-opentracing"
|
||||
)
|
||||
|
||||
// Trace holds the tracer and endpoint info
|
||||
type Trace struct {
|
||||
Next middleware.Handler
|
||||
Next middleware.Handler
|
||||
ServiceEndpoint string
|
||||
Endpoint string
|
||||
EndpointType string
|
||||
Tracer ot.Tracer
|
||||
Once sync.Once
|
||||
Endpoint string
|
||||
EndpointType string
|
||||
Tracer ot.Tracer
|
||||
Once sync.Once
|
||||
}
|
||||
|
||||
// OnStartup sets up the tracer
|
||||
@@ -52,10 +52,12 @@ func (t *Trace) setupZipkin() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Trace) Name() (string) {
|
||||
// Name implements the Handler interface.
|
||||
func (t *Trace) Name() string {
|
||||
return "trace"
|
||||
}
|
||||
|
||||
// ServeDNS implements the middleware.Handle interface.
|
||||
func (t *Trace) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||
span := t.Tracer.StartSpan("servedns")
|
||||
defer span.Finish()
|
||||
|
||||
Reference in New Issue
Block a user