Documentation ¶
Overview ¶
Package opentracingutil provides more utilities for dealing with opentracing and context.Context's.
Index ¶
- func Duration(key string, t time.Duration) log.Field
- func SpanFromContextOrNoop(ctx context.Context) opentracing.Span
- func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
- func Time(key string, t time.Time) log.Field
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Duration ¶
Duration is a log.Field for Duration values. It translates to the standard Go duration format (Duration.String()).
func SpanFromContextOrNoop ¶
SpanFromContextOrNoop is the same as opentracing.SpanFromContext, but instead of returning nil, it returns a NoopTracer span if ctx doesn't already have an associated span. Use this over opentracing.StartSpanFromContext if you need access to the current span, (e.g. if you don't want to start a child span).
NB: if there is no span in the context, the span returned by this function is a noop, and won't be attached to the context; if you want a proper span, either start one and pass it in, or start one in your function.
func StartSpanFromContext ¶
func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
StartSpanFromContext is the same as opentracing.StartSpanFromContext, but instead of always using the global tracer, it attempts to use the parent span's tracer if it's available. This behavior is (arguably) more flexible--it allows a locally set tracer to be used when needed (as in tests)--while being equivalent to the original in most contexts. See https://github.com/opentracing/opentracing-go/issues/149 for more discussion.
Types ¶
This section is empty.