tracing

package
v0.0.0-...-a05c9f2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ForceTracingBaggageKey = "x-force-tracing"

ForceTracingBaggageKey - force sampling header.

Variables

This section is empty.

Functions

func ContextWithTracer

func ContextWithTracer(ctx context.Context, tracer opentracing.Tracer) context.Context

ContextWithTracer returns a new `context.Context` that holds a reference to given opentracing.Tracer.

func CopyTraceContext

func CopyTraceContext(trgt, src context.Context) context.Context

CopyTraceContext copies the necessary trace context from given source context to target context.

func DoInSpan

func DoInSpan(ctx context.Context, operationName string, doFn func(context.Context), opts ...opentracing.StartSpanOption)

DoInSpan executes function doFn inside new span with `operationName` name and hooking as child to a span found within given context if any. It uses opentracing.Tracer propagated in context. If no found, it uses noop tracer notification.

func DoWithSpan

func DoWithSpan(ctx context.Context, operationName string, doFn func(context.Context, opentracing.Span), opts ...opentracing.StartSpanOption)

DoWithSpan executes function doFn inside new span with `operationName` name and hooking as child to a span found within given context if any. It uses opentracing.Tracer propagated in context. If no found, it uses noop tracer notification.

func GinMiddleware

func GinMiddleware(tracer opentracing.Tracer, name string, logger log.Logger) gin.HandlerFunc

func HTTPAutoTripperware

func HTTPAutoTripperware(logger log.Logger, next http.RoundTripper) http.RoundTripper

HTTPAutoTripperware is same as HTTPTripperware, but auto start child span and call span finish.

func HTTPMiddleware

func HTTPMiddleware(tracer opentracing.Tracer, name string, logger log.Logger, next http.Handler) http.HandlerFunc

HTTPMiddleware returns an HTTP handler that injects the given tracer and starts a new server span. If any client span is fetched from the wire, we include that as our parent.

func HTTPTripperware

func HTTPTripperware(logger log.Logger, next http.RoundTripper) http.RoundTripper

HTTPTripperware returns HTTP tripper that assumes given span in context as client child span and injects it into the wire. NOTE: It assumes tracer is given in request context. Also, it is caller responsibility to finish span.

func StartSpan

func StartSpan(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)

StartSpan starts and returns span with `operationName` and hooking as child to a span found within given context if any. It uses opentracing.Tracer propagated in context. If no found, it uses noop tracer without notification.

Types

type Tracer

type Tracer interface {
	GetTraceIDFromSpanContext(ctx opentracing.SpanContext) (string, bool)
}

Tracer interface to provide GetTraceIDFromSpanContext method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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