From 088b8fb348df1faca81957a07dda51e5b3aac157 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 23 Feb 2018 11:16:03 +0100 Subject: [PATCH] Fix tracer value in KV --- middlewares/tracing/tracing.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/middlewares/tracing/tracing.go b/middlewares/tracing/tracing.go index a0ef140ea..eeca54877 100644 --- a/middlewares/tracing/tracing.go +++ b/middlewares/tracing/tracing.go @@ -19,10 +19,25 @@ type Tracing struct { Jaeger *jaeger.Config `description:"Settings for jaeger"` Zipkin *zipkin.Config `description:"Settings for zipkin"` - opentracing.Tracer + tracer opentracing.Tracer closer io.Closer } +// StartSpan delegates to opentracing.Tracer +func (t *Tracing) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span { + return t.tracer.StartSpan(operationName, opts...) +} + +// Inject delegates to opentracing.Tracer +func (t *Tracing) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error { + return t.tracer.Inject(sm, format, carrier) +} + +// Extract delegates to opentracing.Tracer +func (t *Tracing) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error) { + return t.tracer.Extract(format, carrier) +} + // Backend describes things we can use to setup tracing type Backend interface { Setup(serviceName string) (opentracing.Tracer, io.Closer, error) @@ -34,9 +49,9 @@ func (t *Tracing) Setup() { switch t.Backend { case jaeger.Name: - t.Tracer, t.closer, err = t.Jaeger.Setup(t.ServiceName) + t.tracer, t.closer, err = t.Jaeger.Setup(t.ServiceName) case zipkin.Name: - t.Tracer, t.closer, err = t.Zipkin.Setup(t.ServiceName) + t.tracer, t.closer, err = t.Zipkin.Setup(t.ServiceName) default: log.Warnf("Unknown tracer %q", t.Backend) return @@ -49,7 +64,7 @@ func (t *Tracing) Setup() { // IsEnabled determines if tracing was successfully activated func (t *Tracing) IsEnabled() bool { - if t == nil || t.Tracer == nil { + if t == nil || t.tracer == nil { return false } return true