Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision int32
Decision gives the status of sampling decision.
const ( // Unspecified indicates that the status of the decision was not set yet. Unspecified Decision = iota // Pending indicates that the policy was not evaluated yet. Pending // Sampled is used to indicate that the decision was already taken // to sample the data. Sampled // NotSampled is used to indicate that the decision was already taken // to not sample the data. NotSampled // Dropped is used to indicate that a trace should be dropped regardless of // all other decisions. Dropped // Error is used to indicate that policy evaluation was not succeeded. Error // InvertSampled is used on the invert match flow and indicates to sample // the data. // // Deprecated: Drop policies should be used instead of invert decisions. InvertSampled // InvertNotSampled is used on the invert match flow and indicates to not // sample the data. // // Deprecated: Drop policies should be used instead of invert decisions. InvertNotSampled )
type Evaluator ¶
type Evaluator interface {
// Evaluate looks at the trace data and returns a corresponding SamplingDecision.
Evaluate(ctx context.Context, traceID pcommon.TraceID, trace *TraceData) (Decision, error)
// IsStateful reports whether decisions can depend on prior evaluations/state.
IsStateful() bool
}
Evaluator implements a tail-based sampling policy evaluator, which makes a sampling decision for a given trace when requested.
type ThresholdEvaluator ¶ added in v0.157.0
type ThresholdEvaluator interface {
Evaluator
// EvaluateWithThreshold returns the policy's Decision along with
// the effective Threshold. The Threshold is only meaningful when
// Decision is Sampled.
EvaluateWithThreshold(ctx context.Context, traceID pcommon.TraceID, trace *TraceData) (Decision, sampling.Threshold, error)
}
ThresholdEvaluator is implemented by policies that can report the effective OpenTelemetry sampling threshold they would advertise on outgoing tracestate. Implementing this is optional: policies that do not report a threshold are treated by the processor as Sampled with sampling.AlwaysSampleThreshold (i.e., always-sample for matching items, dominates downstream min(th) reduction).
func AsThresholdEvaluator ¶ added in v0.157.0
func AsThresholdEvaluator(e Evaluator) ThresholdEvaluator
AsThresholdEvaluator returns e as a ThresholdEvaluator. If e already implements ThresholdEvaluator it is returned unchanged; otherwise e is wrapped in an adapter that reports sampling.AlwaysSampleThreshold (i.e., "sampled with no quantifiable threshold") whenever Evaluate returns Sampled. This lets callers query an effective sampling threshold from any Evaluator without per-call type assertions.
type TraceData ¶
type TraceData struct {
// SpanCount track the number of spans on the trace.
SpanCount int64
// SizeBytes is how many bytes we have accumulated for the trace.
SizeBytes uint64
// ReceivedBatches stores all the batches received for the trace.
ReceivedBatches ptrace.Traces
}
TraceData stores the sampling related trace data.