Fix <nil> tracer value in KV
This commit is contained in:
parent
e28ebf1c62
commit
088b8fb348
1 changed files with 19 additions and 4 deletions
|
@ -19,10 +19,25 @@ type Tracing struct {
|
||||||
Jaeger *jaeger.Config `description:"Settings for jaeger"`
|
Jaeger *jaeger.Config `description:"Settings for jaeger"`
|
||||||
Zipkin *zipkin.Config `description:"Settings for zipkin"`
|
Zipkin *zipkin.Config `description:"Settings for zipkin"`
|
||||||
|
|
||||||
opentracing.Tracer
|
tracer opentracing.Tracer
|
||||||
closer io.Closer
|
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
|
// Backend describes things we can use to setup tracing
|
||||||
type Backend interface {
|
type Backend interface {
|
||||||
Setup(serviceName string) (opentracing.Tracer, io.Closer, error)
|
Setup(serviceName string) (opentracing.Tracer, io.Closer, error)
|
||||||
|
@ -34,9 +49,9 @@ func (t *Tracing) Setup() {
|
||||||
|
|
||||||
switch t.Backend {
|
switch t.Backend {
|
||||||
case jaeger.Name:
|
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:
|
case zipkin.Name:
|
||||||
t.Tracer, t.closer, err = t.Zipkin.Setup(t.ServiceName)
|
t.tracer, t.closer, err = t.Zipkin.Setup(t.ServiceName)
|
||||||
default:
|
default:
|
||||||
log.Warnf("Unknown tracer %q", t.Backend)
|
log.Warnf("Unknown tracer %q", t.Backend)
|
||||||
return
|
return
|
||||||
|
@ -49,7 +64,7 @@ func (t *Tracing) Setup() {
|
||||||
|
|
||||||
// IsEnabled determines if tracing was successfully activated
|
// IsEnabled determines if tracing was successfully activated
|
||||||
func (t *Tracing) IsEnabled() bool {
|
func (t *Tracing) IsEnabled() bool {
|
||||||
if t == nil || t.Tracer == nil {
|
if t == nil || t.tracer == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in a new issue