opentracingutil

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package opentracingutil provides more utilities for dealing with opentracing and context.Context's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Duration

func Duration(key string, t time.Duration) log.Field

Duration is a log.Field for Duration values. It translates to the standard Go duration format (Duration.String()).

func SpanFromContextOrNoop

func SpanFromContextOrNoop(ctx context.Context) opentracing.Span

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.

func Time

func Time(key string, t time.Time) log.Field

Time is a log.Field for time.Time values. It translates to RF3339 formatted time strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL