otel: go.opentelemetry.io/otel/sdk/trace Index | Files | Directories

package trace

import "go.opentelemetry.io/otel/sdk/trace"

Package trace contains support for OpenTelemetry distributed tracing.

The following assumes a basic familiarity with OpenTelemetry concepts. See https://opentelemetry.io.

Index

Package Files

attributesMap.go batch_span_processor.go config.go doc.go evictedqueue.go id_generator.go provider.go sampling.go simple_span_processor.go span.go span_processor.go trace.go trace_go11.go tracer.go

Constants

const (
    // DefaultMaxEventsPerSpan is default max number of message events per span
    DefaultMaxEventsPerSpan = 128

    // DefaultMaxAttributesPerSpan is default max number of attributes per span
    DefaultMaxAttributesPerSpan = 32

    // DefaultMaxLinksPerSpan is default max number of links per span
    DefaultMaxLinksPerSpan = 32
)

func RegisterSpanProcessor Uses

func RegisterSpanProcessor(e SpanProcessor)

RegisterSpanProcessor adds to the list of SpanProcessors that will receive sampled trace spans.

func UnregisterSpanProcessor Uses

func UnregisterSpanProcessor(s SpanProcessor)

UnregisterSpanProcessor removes from the list of SpanProcessors the SpanProcessor that was registered with the given name.

type BatchSpanProcessor Uses

type BatchSpanProcessor struct {
    // contains filtered or unexported fields
}

BatchSpanProcessor implements SpanProcessor interfaces. It is used by exporters to receive export.SpanData asynchronously. Use BatchSpanProcessorOptions to change the behavior of the processor.

func NewBatchSpanProcessor Uses

func NewBatchSpanProcessor(e export.SpanBatcher, opts ...BatchSpanProcessorOption) (*BatchSpanProcessor, error)

NewBatchSpanProcessor creates a new instance of BatchSpanProcessor for a given export. It returns an error if exporter is nil. The newly created BatchSpanProcessor should then be registered with sdk using RegisterSpanProcessor.

func (*BatchSpanProcessor) OnEnd Uses

func (bsp *BatchSpanProcessor) OnEnd(sd *export.SpanData)

OnEnd method enqueues export.SpanData for later processing.

func (*BatchSpanProcessor) OnStart Uses

func (bsp *BatchSpanProcessor) OnStart(sd *export.SpanData)

OnStart method does nothing.

func (*BatchSpanProcessor) Shutdown Uses

func (bsp *BatchSpanProcessor) Shutdown()

Shutdown flushes the queue and waits until all spans are processed. It only executes once. Subsequent call does nothing.

type BatchSpanProcessorOption Uses

type BatchSpanProcessorOption func(o *BatchSpanProcessorOptions)

func WithBlocking Uses

func WithBlocking() BatchSpanProcessorOption

func WithMaxExportBatchSize Uses

func WithMaxExportBatchSize(size int) BatchSpanProcessorOption

func WithMaxQueueSize Uses

func WithMaxQueueSize(size int) BatchSpanProcessorOption

func WithScheduleDelayMillis Uses

func WithScheduleDelayMillis(delay time.Duration) BatchSpanProcessorOption

type BatchSpanProcessorOptions Uses

type BatchSpanProcessorOptions struct {
    // MaxQueueSize is the maximum queue size to buffer spans for delayed processing. If the
    // queue gets full it drops the spans. Use BlockOnQueueFull to change this behavior.
    // The default value of MaxQueueSize is 2048.
    MaxQueueSize int

    // ScheduledDelayMillis is the delay interval in milliseconds between two consecutive
    // processing of batches.
    // The default value of ScheduledDelayMillis is 5000 msec.
    ScheduledDelayMillis time.Duration

    // MaxExportBatchSize is the maximum number of spans to process in a single batch.
    // If there are more than one batch worth of spans then it processes multiple batches
    // of spans one batch after the other without any delay.
    // The default value of MaxExportBatchSize is 512.
    MaxExportBatchSize int

    // BlockOnQueueFull blocks onEnd() and onStart() method if the queue is full
    // AND if BlockOnQueueFull is set to true.
    // Blocking option should be used carefully as it can severely affect the performance of an
    // application.
    BlockOnQueueFull bool
}

type Config Uses

type Config struct {
    // DefaultSampler is the default sampler used when creating new spans.
    DefaultSampler Sampler

    // IDGenerator is for internal use only.
    IDGenerator internal.IDGenerator

    // MaxEventsPerSpan is max number of message events per span
    MaxEventsPerSpan int

    // MaxAnnotationEventsPerSpan is max number of attributes per span
    MaxAttributesPerSpan int

    // MaxLinksPerSpan is max number of links per span
    MaxLinksPerSpan int
}

Config represents the global tracing configuration.

type Provider Uses

type Provider struct {
    // contains filtered or unexported fields
}

func NewProvider Uses

func NewProvider(opts ...ProviderOption) (*Provider, error)

NewProvider creates an instance of trace provider. Optional parameter configures the provider with common options applicable to all tracer instances that will be created by this provider.

func (*Provider) ApplyConfig Uses

func (p *Provider) ApplyConfig(cfg Config)

ApplyConfig changes the configuration of the provider. If a field in the configuration is empty or nil then its original value is preserved.

func (*Provider) RegisterSpanProcessor Uses

func (p *Provider) RegisterSpanProcessor(s SpanProcessor)

RegisterSpanProcessor adds the given SpanProcessor to the list of SpanProcessors

func (*Provider) Tracer Uses

func (p *Provider) Tracer(name string) apitrace.Tracer

Tracer with the given name. If a tracer for the given name does not exist, it is created first. If the name is empty, DefaultTracerName is used.

func (*Provider) UnregisterSpanProcessor Uses

func (p *Provider) UnregisterSpanProcessor(s SpanProcessor)

UnregisterSpanProcessor removes the given SpanProcessor from the list of SpanProcessors

type ProviderOption Uses

type ProviderOption func(*ProviderOptions)

func WithBatcher Uses

func WithBatcher(b export.SpanBatcher, bopts ...BatchSpanProcessorOption) ProviderOption

WithBatch options appends the batcher to the existing list of Batchers. This option can be used multiple times. The Batchers are wrapped into BatchedSpanProcessors and registered with the provider.

func WithConfig Uses

func WithConfig(config Config) ProviderOption

WithConfig option sets the configuration to provider.

func WithSyncer Uses

func WithSyncer(syncer export.SpanSyncer) ProviderOption

WithSyncer options appends the syncer to the existing list of Syncers. This option can be used multiple times. The Syncers are wrapped into SimpleSpanProcessors and registered with the provider.

type ProviderOptions Uses

type ProviderOptions struct {
    // contains filtered or unexported fields
}

ProviderOptions

type Sampler Uses

type Sampler func(SamplingParameters) SamplingDecision

Sampler decides whether a trace should be sampled and exported.

func AlwaysParentSample Uses

func AlwaysParentSample() Sampler

AlwaysParentSample returns a Sampler that samples a trace only if the parent span is sampled. This Sampler is a passthrough to the ProbabilitySampler with a fraction of value 0.

func AlwaysSample Uses

func AlwaysSample() Sampler

AlwaysSample returns a Sampler that samples every trace. Be careful about using this sampler in a production application with significant traffic: a new trace will be started and exported for every request.

func NeverSample Uses

func NeverSample() Sampler

NeverSample returns a Sampler that samples no traces.

func ProbabilitySampler Uses

func ProbabilitySampler(fraction float64) Sampler

ProbabilitySampler samples a given fraction of traces. Fractions >= 1 will always sample. If the parent span is sampled, then it's child spans will automatically be sampled. Fractions <0 are treated as zero, but spans may still be sampled if their parent is.

type SamplingDecision Uses

type SamplingDecision struct {
    Sample bool
}

SamplingDecision is the value returned by a Sampler.

type SamplingParameters Uses

type SamplingParameters struct {
    ParentContext   core.SpanContext
    TraceID         core.TraceID
    SpanID          core.SpanID
    Name            string
    HasRemoteParent bool
}

SamplingParameters contains the values passed to a Sampler.

type SimpleSpanProcessor Uses

type SimpleSpanProcessor struct {
    // contains filtered or unexported fields
}

SimpleSpanProcessor implements SpanProcessor interfaces. It is used by exporters to receive SpanData synchronously when span is finished.

func NewSimpleSpanProcessor Uses

func NewSimpleSpanProcessor(e export.SpanSyncer) *SimpleSpanProcessor

NewSimpleSpanProcessor creates a new instance of SimpleSpanProcessor for a given export.

func (*SimpleSpanProcessor) OnEnd Uses

func (ssp *SimpleSpanProcessor) OnEnd(sd *export.SpanData)

OnEnd method exports SpanData using associated export.

func (*SimpleSpanProcessor) OnStart Uses

func (ssp *SimpleSpanProcessor) OnStart(sd *export.SpanData)

OnStart method does nothing.

func (*SimpleSpanProcessor) Shutdown Uses

func (ssp *SimpleSpanProcessor) Shutdown()

Shutdown method does nothing. There is no data to cleanup.

type SpanProcessor Uses

type SpanProcessor interface {

    // OnStart method is invoked when span is started. It is a synchronous call
    // and hence should not block.
    OnStart(sd *export.SpanData)

    // OnEnd method is invoked when span is finished. It is a synchronous call
    // and hence should not block.
    OnEnd(sd *export.SpanData)

    // Shutdown is invoked when SDK shutsdown. Use this call to cleanup any processor
    // data. No calls to OnStart and OnEnd method is invoked after Shutdown call is
    // made. It should not be blocked indefinitely.
    Shutdown()
}

SpanProcessor is interface to add hooks to start and end method invocations.

Directories

PathSynopsis
internalPackage internal provides trace internals.

Package trace imports 17 packages (graph) and is imported by 8 packages. Updated 2020-02-12. Refresh now. Tools for package owners.