Documentation
¶
Overview ¶
Package trace trace
Package trace trace ¶
Package trace trace
Index ¶
- Constants
- Variables
- func DefaultSampler() sdktrace.Sampler
- func NewBatchSpanProcessor(exporter sdktrace.SpanExporter, options ...BatchSpanProcessorOption) sdktrace.SpanProcessor
- func NewSampler(tpsTenantID string, samplerConfig SamplerConfig, opts ...SamplerOption) sdktrace.Sampler
- func SetNoopTracerProvider()
- type BatchSpanProcessorOption
- func WithBatchTimeout(delay time.Duration) BatchSpanProcessorOption
- func WithBlocking() BatchSpanProcessorOption
- func WithExportTimeout(timeout time.Duration) BatchSpanProcessorOption
- func WithMaxExportBatchSize(size int) BatchSpanProcessorOption
- func WithMaxPacketSize(size int) BatchSpanProcessorOption
- func WithMaxQueueSize(size int) BatchSpanProcessorOption
- type BatchSpanProcessorOptions
- type DeferredSampleConfig
- type DeferredSampleProcessor
- type DeferredSampler
- type GetCalleeMethodInfo
- type MethodFraction
- type MethodInfo
- type Sampler
- type SamplerConfig
- type SamplerOption
- type SamplerOptions
- type SpecialFraction
Constants ¶
const ( // DefaultMaxQueueSize default max queue size DefaultMaxQueueSize = 2048 // DefaultBatchTimeout default batch timeout DefaultBatchTimeout = 5000 * time.Millisecond // DefaultExportTimeout default export timeout DefaultExportTimeout = 30000 * time.Millisecond // DefaultMaxExportBatchSize default max export batch size DefaultMaxExportBatchSize = 512 // DefaultMaxBatchedPacketSize default max batched packet size DefaultMaxBatchedPacketSize = 2097152 )
Defaults for BatchSpanProcessorOptions.
Variables ¶
var ( // ForceSamplerKey for debug ForceSamplerKey = attribute.Key("trace.force.sample") )
var NoopTracerProvider = trace.NewNoopTracerProvider()
NoopTracerProvider implementation a tracer provider that will do nothing use code lines blow to set a noop tracer otel.SetTracerProvider(NoopTracerProvider)
Functions ¶
func NewBatchSpanProcessor ¶
func NewBatchSpanProcessor(exporter sdktrace.SpanExporter, options ...BatchSpanProcessorOption) sdktrace.SpanProcessor
NewBatchSpanProcessor creates a new SpanProcessor that will send completed span batches to the exporter with the supplied options.
If the exporter is nil, the span processor will preform no action.
func NewSampler ¶
func NewSampler( tpsTenantID string, samplerConfig SamplerConfig, opts ...SamplerOption, ) sdktrace.Sampler
NewSampler .
func SetNoopTracerProvider ¶
func SetNoopTracerProvider()
SetNoopTracerProvider set the global trace provider as noop
Types ¶
type BatchSpanProcessorOption ¶
type BatchSpanProcessorOption func(o *BatchSpanProcessorOptions)
BatchSpanProcessorOption BatchSpanProcessor Option helper
func WithBatchTimeout ¶
func WithBatchTimeout(delay time.Duration) BatchSpanProcessorOption
WithBatchTimeout set BatchTimeout helper
func WithExportTimeout ¶
func WithExportTimeout(timeout time.Duration) BatchSpanProcessorOption
WithExportTimeout set ExportTimeout helper
func WithMaxExportBatchSize ¶
func WithMaxExportBatchSize(size int) BatchSpanProcessorOption
WithMaxExportBatchSize set MaxExportBatchSize helper
func WithMaxPacketSize ¶
func WithMaxPacketSize(size int) BatchSpanProcessorOption
WithMaxPacketSize set MaxPacketSize helper
func WithMaxQueueSize ¶
func WithMaxQueueSize(size int) BatchSpanProcessorOption
WithMaxQueueSize set MaxQueueSize helper
type BatchSpanProcessorOptions ¶
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 // BatchTimeout is the maximum duration for constructing a batch. Processor // forcefully sends available spans when timeout is reached. // The default value of BatchTimeout is 5000 msec. BatchTimeout time.Duration // ExportTimeout specifies the maximum duration for exporting spans. If the timeout // is reached, the export will be cancelled. // The default value of ExportTimeout is 30000 msec. ExportTimeout 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 // MaxPacketSize is the maximum number of packet size that will forcefully trigger a batch process. // The default value of MaxPacketSize is 2M (in bytes) . MaxPacketSize 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 }
BatchSpanProcessorOptions BatchSpanProcessor options
type DeferredSampleConfig ¶
type DeferredSampleConfig struct { Enabled bool // Whether to enable it, if not enabled, there will be no filtering SampleError bool // Sampling error SampleSlowDuration time.Duration // Sampling slow operation }
DeferredSampleConfig deferred sampling configuration
type DeferredSampleProcessor ¶
type DeferredSampleProcessor struct {
// contains filtered or unexported fields
}
DeferredSampleProcessor deferred sampling processor, processing filter conditions after span.End
func NewDeferredSampleProcessor ¶
func NewDeferredSampleProcessor(next sdktrace.SpanProcessor, sampleFunc func(sdktrace.ReadOnlySpan) bool) *DeferredSampleProcessor
NewDeferredSampleProcessor create a new deferred sample processor
func (*DeferredSampleProcessor) ForceFlush ¶
func (p *DeferredSampleProcessor) ForceFlush(ctx context.Context) error
ForceFlush exports all ended spans to the configured Exporter that have not yet been exported. It should only be called when absolutely necessary, such as when using a FaaS provider that may suspend the process after an invocation, but before the Processor can export the completed spans.
func (*DeferredSampleProcessor) OnEnd ¶
func (p *DeferredSampleProcessor) OnEnd(s sdktrace.ReadOnlySpan)
OnEnd is called when span is finished. It is called synchronously and hence not block.
func (*DeferredSampleProcessor) OnStart ¶
func (p *DeferredSampleProcessor) OnStart(parent context.Context, s sdktrace.ReadWriteSpan)
OnStart is called when a span is started. It is called synchronously and should not block.
func (*DeferredSampleProcessor) Shutdown ¶
func (p *DeferredSampleProcessor) Shutdown(ctx context.Context) error
Shutdown is called when the SDK shuts down. Any cleanup or release of resources held by the processor should be done in this call.
Calls to OnStart, OnEnd, or ForceFlush after this has been called should be ignored.
All timeouts and cancellations contained in ctx must be honored, this should not block indefinitely.
type DeferredSampler ¶
type DeferredSampler func(sdktrace.ReadOnlySpan) bool
DeferredSampler deferred sampling, processing the filtering conditions after span.End. If true is returned, it is retained, and if false is returned, it is dropped.
func NewDeferredSampler ¶
func NewDeferredSampler(cfg DeferredSampleConfig) DeferredSampler
NewDeferredSampler crate a new deferred sampler
type GetCalleeMethodInfo ¶
type GetCalleeMethodInfo func(context.Context) MethodInfo
GetCalleeMethodInfo .
var DefaultGetCalleeMethodInfo GetCalleeMethodInfo = nil
DefaultGetCalleeMethodInfo .
type MethodFraction ¶
type MethodFraction struct { // Fraction Specified sampling rate Fraction float64 // contains filtered or unexported fields }
MethodFraction method special fraction
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler .
func (*Sampler) Description ¶
Description return the description of Sampler
func (*Sampler) ShouldSample ¶
func (ws *Sampler) ShouldSample(p sdktrace.SamplingParameters) sdktrace.SamplingResult
ShouldSample sampler ShouldSample implementation
type SamplerConfig ¶
type SamplerConfig struct { // Fraction default sampling fraction Fraction float64 // SpecialFractions specified fractions SpecialFractions map[string]SpecialFraction // SamplerServiceAddr sampler service address SamplerServiceAddr string // SyncInterval sampler sync interval SyncInterval time.Duration // contains filtered or unexported fields }
SamplerConfig sampler fractions config
type SamplerOptions ¶
type SamplerOptions struct { // DefaultSamplingDecision Default sampling decision DefaultSamplingDecision sdktrace.SamplingDecision }
SamplerOptions .
type SpecialFraction ¶
type SpecialFraction struct { DefaultFraction float64 Methods map[string]MethodFraction // contains filtered or unexported fields }
SpecialFraction special fraction config