Documentation ¶
Index ¶
- Constants
- func ChildOf(ctx leafTracer.SpanContext) leafTracer.StartSpanOption
- func ContextWithSpan(ctx context.Context, s Span) context.Context
- func Extract(carrier interface{}) (leafTracer.SpanContext, error)
- func FinishTime(t time.Time) leafTracer.FinishOption
- func Inject(ctx leafTracer.SpanContext, carrier interface{}) error
- func NoDebugStack() leafTracer.FinishOption
- func StackFrames(n, skip uint) leafTracer.FinishOption
- func Start(t leafTracer.Tracer)
- func StartTime(t time.Time) leafTracer.StartSpanOption
- func Stop()
- func Tag(k string, v interface{}) leafTracer.StartSpanOption
- func WithError(err error) leafTracer.FinishOption
- func WithSpanID(id uint64) leafTracer.StartSpanOption
- type Span
- type SpanContext
- type Tracer
Constants ¶
const ( HttpRequestKey = `http-request` HttpResponseWriterKey = `http-response-writer` )
Variables ¶
This section is empty.
Functions ¶
func ChildOf ¶
func ChildOf(ctx leafTracer.SpanContext) leafTracer.StartSpanOption
ChildOf tells StartSpan to use the given span context as a parent for the created span.s
func ContextWithSpan ¶
ContextWithSpan returns a copy of the given context which includes the span s.
func Extract ¶
func Extract(carrier interface{}) (leafTracer.SpanContext, error)
Extract extracts a SpanContext from the carrier. The carrier is expected to implement TextMapReader, otherwise an error is returned. If the tracer is not started, calling this function is a no-op.
func FinishTime ¶
func FinishTime(t time.Time) leafTracer.FinishOption
FinishTime sets the given time as the finishing time for the span. By default, the current time is used.
func Inject ¶
func Inject(ctx leafTracer.SpanContext, carrier interface{}) error
Inject injects the given SpanContext into the carrier. The carrier is expected to implement TextMapWriter, otherwise an error is returned. If the tracer is not started, calling this function is a no-op.
func NoDebugStack ¶
func NoDebugStack() leafTracer.FinishOption
NoDebugStack prevents any error presented using the WithError finishing option from generating a stack trace. This is useful in situations where errors are frequent and performance is critical.
func StackFrames ¶
func StackFrames(n, skip uint) leafTracer.FinishOption
StackFrames limits the number of stack frames included into erroneous spans to n, starting from skip.
func Start ¶
func Start(t leafTracer.Tracer)
Start starts the tracer with the initialized tracers. It will stop and replace any running tracer, meaning that calling it several times will result in a restart of the tracer by replacing the current instance with a new one.
func StartTime ¶
func StartTime(t time.Time) leafTracer.StartSpanOption
StartTime sets a custom time as the start time for the created span. By default a span is started using the creation time.
func Tag ¶
func Tag(k string, v interface{}) leafTracer.StartSpanOption
Tag sets the given key/value pair as a tag on the started Span.
func WithError ¶
func WithError(err error) leafTracer.FinishOption
WithError marks the span as having had an error. It uses the information from err to set tags such as the error message, error type and stack trace. It has no effect if the error is nil.
func WithSpanID ¶
func WithSpanID(id uint64) leafTracer.StartSpanOption
WithSpanID sets the SpanID on the started span, instead of using a random number. If there is no parent Span (eg from ChildOf), then the TraceID will also be set to the value given here.
Types ¶
type Span ¶
type Span = leafTracer.Span
Span is an alias for leafTracer.Span. It is here to allow godoc to group methods returning leafTracer.Span. It is recommended and is considered more correct to refer to this type as leafTracer.Span instead.
func SpanFromContext ¶
SpanFromContext returns the span contained in the given context. A second return value indicates if a span was found in the context. If no span is found, a no-op span is returned.
func StartSpan ¶
func StartSpan(operationName string, opts ...leafTracer.StartSpanOption) Span
StartSpan starts a new span with the given operation name and set of options. If the tracer is not started, calling this function is a no-op.
func StartSpanFromContext ¶
func StartSpanFromContext(ctx context.Context, operationName string, opts ...leafTracer.StartSpanOption) (Span, context.Context)
StartSpanFromContext returns a new span with the given operation name and options. If a span is found in the context, it will be used as the parent of the resulting span. If the ChildOf option is passed, the span from context will take precedence over it as the parent span.
type SpanContext ¶
type SpanContext = leafTracer.SpanContext
func NoopSpanContext ¶
func NoopSpanContext() SpanContext