tracer

package
v0.0.0-...-0829b1e Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 4 Imported by: 13

Documentation

Index

Constants

View Source
const (
	HttpRequestKey        = `http-request`
	HttpResponseWriterKey = `http-response-writer`
)

Variables

This section is empty.

Functions

func ChildOf

ChildOf tells StartSpan to use the given span context as a parent for the created span.s

func ContextWithSpan

func ContextWithSpan(ctx context.Context, s Span) context.Context

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 Stop

func Stop()

Stop stops the started tracer. Subsequent calls are valid but become no-op.

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 NoopSpan

func NoopSpan() Span

func SpanFromContext

func SpanFromContext(ctx context.Context) (Span, bool)

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

type Tracer

type Tracer = leafTracer.Tracer

func NoopTracer

func NoopTracer() Tracer

Jump to

Keyboard shortcuts

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