Documentation
¶
Overview ¶
Package sampling provides rate based sampling for use by components that need to include a fraction of items in a "sampled" set (e.g. loki.secretfilter for processing rate, loki.process.stages.sampling for drop rate).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRate ¶
ValidateRate returns an error if rate is not in [0.0, 1.0].
Types ¶
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler decides probabilistically whether an item should be included in the sample (ShouldSample returns true). Rate is the probability of inclusion; 0 = never, 1 = always, 0.5 = ~50%.
func NewSampler ¶
NewSampler returns a Sampler for the given rate. Rate must be in [0.0, 1.0]; call ValidateRate first or the sampler behavior for out-of-range rate is undefined.
func (*Sampler) ShouldSample ¶
ShouldSample returns true with probability equal to the rate used to create or update the sampler. Rate 0 → always false; rate 1 → always true; otherwise uses the same probabilistic algorithm as Jaeger's ProbabilisticSampler.