Skip to content

Commit

Permalink
Merge pull request #1 from Vinelab/graceful_inject
Browse files Browse the repository at this point in the history
Define errors out of existence
  • Loading branch information
adiachenko committed Aug 27, 2019
2 parents ee0768f + 5bea0cb commit fac9736
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
5 changes: 0 additions & 5 deletions drivers/noop/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ func (tracer *Tracer) Extract(carrier interface{}, format string) (tracing.SpanC
// Inject implicitly serializes current span context using the format descriptor that
// tells how to encode trace info in the carrier parameters
func (tracer *Tracer) Inject(carrier interface{}, format string) error {
span := tracer.currentSpan
if span == nil {
return tracing.ErrMissingTraceContext
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/zipkin/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (tracer *Tracer) Extract(carrier interface{}, format string) (tracing.SpanC
func (tracer *Tracer) Inject(carrier interface{}, format string) error {
span := tracer.currentSpan
if span == nil {
return tracing.ErrMissingTraceContext
return nil
}

injector, ok := tracer.injectionFormats[format]
Expand Down
7 changes: 0 additions & 7 deletions errors.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package tracing

import (
"errors"
"fmt"
)

var (
// ErrMissingTraceContext is returned when trying to implicitly inject SpanContext
// and there is no active span
ErrMissingTraceContext = errors.New("cannot obtain context because there is no active span")
)

// UnregisteredFormatError is returned when you tried to inject/extract trace context
// using unregistered format or when there is a mismatch between format and extractor
type UnregisteredFormatError struct {
Expand Down

0 comments on commit fac9736

Please sign in to comment.