wtracing

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 3 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithSpan

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

ContextWithSpan returns a copy of the provided context with the provided span set on it.

func ContextWithTracer

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

ContextWithTracer returns a copy of the provided context with the provided Tracer included as a value.

Types

type Endpoint

type Endpoint struct {
	ServiceName string
	IPv4        net.IP
	IPv6        net.IP
	Port        uint16
}

type Kind

type Kind string

Kind clarifies context of timestamp, duration and WithRemoteEndpoint in a span.

const (
	Undetermined Kind = ""
	Client       Kind = "CLIENT"
	Server       Kind = "SERVER"
	Producer     Kind = "PRODUCER"
	Consumer     Kind = "CONSUMER"
)

Available Kind values

type Reporter

type Reporter interface {
	// Send Span data to the reporter
	Send(SpanModel)

	// Close the reporter
	Close() error
}

func NewNoopReporter

func NewNoopReporter() Reporter

type Sampler

type Sampler func(id uint64) bool

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

func SpanFromContext(ctx context.Context) Span

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 SpanContext struct {
	TraceID  TraceID
	ID       SpanID
	ParentID *SpanID
	Debug    bool
	Sampled  *bool
	Err      error
}

type SpanExtractor

type SpanExtractor func() SpanContext

type SpanID

type SpanID string

type SpanInjector

type SpanInjector func(sc SpanContext)

type SpanModel

type SpanModel struct {
	SpanContext

	Name           string
	Kind           Kind
	Timestamp      time.Time
	Duration       time.Duration
	LocalEndpoint  *Endpoint
	RemoteEndpoint *Endpoint
	Tags           map[string]string
}

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

func TraceIDFromContext(ctx context.Context) TraceID

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

func TracerFromContext(ctx context.Context) Tracer

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

type TracerOptionImpl struct {
	Sampler       Sampler
	LocalEndpoint *Endpoint
}

func FromTracerOptions

func FromTracerOptions(opts ...TracerOption) *TracerOptionImpl

Directories

Path Synopsis
propagation
b3

Jump to

Keyboard shortcuts

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