Documentation ¶
Index ¶
- func ContextWithSpan(ctx context.Context, s Span) context.Context
- func ContextWithTracer(ctx context.Context, tracer Tracer) context.Context
- type Endpoint
- type Kind
- type Reporter
- type Sampler
- type Span
- type SpanContext
- type SpanExtractor
- type SpanID
- type SpanInjector
- type SpanModel
- type SpanOption
- type SpanOptionImpl
- type TraceID
- type Tracer
- type TracerOption
- type TracerOptionImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithSpan ¶
ContextWithSpan returns a copy of the provided context with the provided span set on it.
Types ¶
type Kind ¶
type Kind string
Kind clarifies context of timestamp, duration and WithRemoteEndpoint in a span.
type Reporter ¶
type Reporter interface { // Send Span data to the reporter Send(SpanModel) // Close the reporter Close() error }
func NewNoopReporter ¶
func NewNoopReporter() Reporter
type Span ¶
type Span interface { Context() SpanContext // Tag sets Tag with given key and value to the Span. If key already exists in // the Span the value will be overridden except for error tags where the first // value is persisted. Tag(key string, value string) // Finish the Span and send to Reporter. Finish() }
func SpanFromContext ¶
SpanFromContext returns the span stored in the provided context, or nil if no span is stored in the context.
func StartSpanFromContext ¶
func StartSpanFromContext(ctx context.Context, tracer Tracer, spanName string, spanOptions ...SpanOption) (Span, context.Context)
StartSpanFromContext starts a new span with the provided parameters using the provided tracer and the span information in the provided context. If the context contains a span, the new span will be configured to be a child span of that span (unless any of the user-provided span options overrides this). Returns the newly started span and a copy of the provided context that has the new span set as its current span. Returns a nil span if the provided tracer is nil.
This function does not read or set the tracer on the provided context. To start a span new span from the tracer set on a context, call StartSpanFromContext(TracerFromContext(ctx), ctx, spanName, spanOptions).
func StartSpanFromTracerInContext ¶
func StartSpanFromTracerInContext(ctx context.Context, spanName string, spanOptions ...SpanOption) (Span, context.Context)
StartSpanFromTracerInContext starts a new span with the provided parameters using the tracer and the span information in the provided context. If the context contains a span, the new span will be configured to be a child span of that span (unless any of the user-provided span options overrides this). Returns the newly started span and a copy of the provided context that has the new span set as its current span.
If the context does not contain a tracer, returns a no-op Span and an unmodified version of the provided context. The span returned by this function is always non-nil.
type SpanContext ¶
type SpanExtractor ¶
type SpanExtractor func() SpanContext
type SpanInjector ¶
type SpanInjector func(sc SpanContext)
type SpanOption ¶
type SpanOption interface {
// contains filtered or unexported methods
}
func WithKind ¶
func WithKind(kind Kind) SpanOption
func WithParent ¶
func WithParent(parent Span) SpanOption
WithParent sets the parent SpanContext to be the context of the specified span. If the provided span is nil, the parent span context is explicitly set to be nil (indicating that the created span is a root span).
func WithParentSpanContext ¶
func WithParentSpanContext(parentCtx SpanContext) SpanOption
WithParentSpanContext sets the parent span context to be the specified span context. If the provided context is valid (TraceID and SpanID are set), the new span will use the same TraceID and set its ParentID to be the SpanID. If the TraceID is set but the SpanID is not, the new span will be a root span and its TraceId and SpanID will both be the same value as the TraceID in the provided context. The debug and sampled values are always inherited (regardless of the other fields).
func WithRemoteEndpoint ¶
func WithRemoteEndpoint(endpoint *Endpoint) SpanOption
func WithSpanTag ¶ added in v1.3.0
func WithSpanTag(name, value string) SpanOption
WithSpanTag adds the tag indexed by name with the value specified to the set of tags defined for this span. If the same name is seen multiple times the most recent will prevail.
type SpanOptionImpl ¶
type SpanOptionImpl struct { RemoteEndpoint *Endpoint ParentSpan *SpanContext Kind Kind Tags map[string]string }
func FromSpanOptions ¶
func FromSpanOptions(opts ...SpanOption) *SpanOptionImpl
type TraceID ¶
type TraceID string
TraceID and SpanID are identifiers for the trace and span. Represented as hex strings.
func TraceIDFromContext ¶
TraceIDFromContext returns the traceId associated with the span stored in the provided context. Returns an empty string if no span is stored in the context.
type Tracer ¶
type Tracer interface {
StartSpan(name string, options ...SpanOption) Span
}
func TracerFromContext ¶
TracerFromContext returns the Tracer stored in the provided context. Returns nil if no Tracer is stored in the context.
type TracerOption ¶
type TracerOption interface {
// contains filtered or unexported methods
}
func WithLocalEndpoint ¶
func WithLocalEndpoint(endpoint *Endpoint) TracerOption
func WithSampler ¶
func WithSampler(sampler Sampler) TracerOption
type TracerOptionImpl ¶
func FromTracerOptions ¶
func FromTracerOptions(opts ...TracerOption) *TracerOptionImpl