diff --git a/observer.go b/observer.go index ebce920..c8cbf61 100644 --- a/observer.go +++ b/observer.go @@ -2,6 +2,8 @@ package otobserver +import opentracing "github.com/opentracing/opentracing-go" + // Observer can be registered with a Tracer to recieve notifications // about new Spans. Tracers are not required to support the Observer API. // The actual registration depends on the implementation, which might look @@ -11,14 +13,18 @@ package otobserver // type Observer interface { // Create and return a span observer. Called when a span starts. + // If the Observer is not interested in the given span, it must return (nil, false). // E.g : // func StartSpan(opName string, opts ...opentracing.StartSpanOption) { - // var sp opentracing.Span - // sso := opentracing.StartSpanOptions{} - // var spObs otobserver.SpanObserver = observer.OnStartSpan(span, opName, sso) - // ... - // } - OnStartSpan(sp Span, operationName string, options StartSpanOptions) SpanObserver + // var sp opentracing.Span + // sso := opentracing.StartSpanOptions{} + // spanObserver, ok := observer.OnStartSpan(span, opName, sso); + // if ok { + // // we have a valid SpanObserver + // } + // ... + // } + OnStartSpan(sp opentracing.Span, operationName string, options opentracing.StartSpanOptions) (SpanObserver, bool) } // SpanObserver is created by the Observer and receives notifications about @@ -29,5 +35,5 @@ type SpanObserver interface { // Callback called from opentracing.Span.SetTag() OnSetTag(key string, value interface{}) // Callback called from opentracing.Span.Finish() - OnFinish(options FinishOptions) + OnFinish(options opentracing.FinishOptions) }