Documentation ¶
Index ¶
- func ContextWithSpan(ctx context.Context, span opentracing.Span) context.Context
- func Extract(ctx context.Context, format interface{}, carrier interface{}) (opentracing.SpanContext, error)
- func Inject(ctx context.Context, sm opentracing.SpanContext, format interface{}, ...) error
- func SpanFromContext(ctx context.Context) opentracing.Span
- func StartSpan(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (span opentracing.Span)
- func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
- func WithContext(ctx context.Context, t Tracer) context.Context
- type Tracer
- type TracerOption
- type TracerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithSpan ¶
ContextWithSpan returns a new `context.Context` that holds a reference to `span`'s SpanContext.
func Extract ¶
func Extract( ctx context.Context, format interface{}, carrier interface{}, ) (opentracing.SpanContext, error)
Extract returns a SpanContext instance given `format` and `carrier`.
Extract calls `Extract` on the context `Tracer`
func Inject ¶
func Inject( ctx context.Context, sm opentracing.SpanContext, format interface{}, carrier interface{}, ) error
Inject takes the `sm` SpanContext instance and injects it for propagation within `carrier`. The actual type of `carrier` depends on the value of `format`.
Inject calls `Inject` on the context `Tracer`
func SpanFromContext ¶
func SpanFromContext(ctx context.Context) opentracing.Span
SpanFromContext returns the `Span` previously associated with `ctx`, or `nil` if no such `Span` could be found.
NOTE: context.Context != SpanContext: the former is Go's intra-process context propagation mechanism, and the latter houses OpenTracing's per-Span identity and baggage information.
func StartSpan ¶
func StartSpan( ctx context.Context, operationName string, opts ...opentracing.StartSpanOption, ) (span opentracing.Span)
StartSpan creates, starts, and returns a new Span with the given `operationName` and incorporate the given StartSpanOption `opts`.
StartSpan calls `StartSpan` on the context `Tracer`
func StartSpanFromContext ¶
func StartSpanFromContext( ctx context.Context, operationName string, opts ...opentracing.StartSpanOption, ) (opentracing.Span, context.Context)
StartSpanFromContext starts and returns a Span with `operationName`, using any Span found within `ctx` as a ChildOfRef. If no such parent could be found, StartSpanFromContext creates a root (parentless) Span.
The second return value is a context.Context object built around the returned Span.
Example usage:
SomeFunction(ctx context.Context, ...) { sp, ctx := tracing.StartSpanFromContext(ctx, "SomeFunction") defer sp.Finish() ... }
Types ¶
type Tracer ¶
type Tracer opentracing.Tracer
Tracer follows the opentracing standard https://opentracing.io
func FromContext ¶
func FromContext(ctx contextutil.ValueContext) Tracer
FromContext returns a `Tracer` instance associated with `ctx`, or the `opentracing.GlobalTracer` if no `Tracer` instance could be found.
type TracerOption ¶
type TracerOption func(*TracerOptions)
TracerOption configures how we set up a job
func WithLogger ¶
func WithLogger(l log.Logger) TracerOption
WithLogger injects a `Logger` to `Tracer`