Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Implement new interfaces for noop types
Browse files Browse the repository at this point in the history
  • Loading branch information
krnowak committed Aug 21, 2019
1 parent f67037d commit 4700b85
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion noop.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package opentracing

import "github.com/opentracing/opentracing-go/log"
import (
"context"

"github.com/opentracing/opentracing-go/log"
)

// A NoopTracer is a trivial, minimum overhead implementation of Tracer
// for which all operations are no-ops.
Expand Down Expand Up @@ -48,11 +52,19 @@ func (n noopSpan) LogEvent(event string) {}
func (n noopSpan) LogEventWithPayload(event string, payload interface{}) {}
func (n noopSpan) Log(data LogData) {}

// noopSpan as SpanExt1
func (n noopSpan) TracerExt1() TracerExt1 { return defaultNoopTracer }

// StartSpan belongs to the Tracer interface.
func (n NoopTracer) StartSpan(operationName string, opts ...StartSpanOption) Span {
return defaultNoopSpan
}

// StartSpanWithContext belongs to the TracerExt1 interface.
func (n NoopTracer) StartSpanWithContext(ctx context.Context, operationName string, opts ...StartSpanOption) (context.Context, SpanExt1) {
return ContextWithSpan(ctx, defaultNoopSpan), defaultNoopSpan
}

// Inject belongs to the Tracer interface.
func (n NoopTracer) Inject(sp SpanContext, format interface{}, carrier interface{}) error {
return nil
Expand Down

0 comments on commit 4700b85

Please sign in to comment.