Class RateLimitingSampler
public class RateLimitingSampler extends Sampler
For example, to allow 10 traces per second, you'd initialize the following:
tracingBuilder.sampler(RateLimitingSampler.create(10));
Appropriate Usage
If the rate is 10 or more traces per second, an attempt is made to distribute the accept decisions equally across the second. For example, if the rate is 100, 10 will pass every decisecond as opposed to bunching all pass decisions at the beginning of the second.
This sampler is efficient, but not as efficient as the BoundarySampler
.
However, this sampler is insensitive to the trace ID and will operate correctly even if they are
not perfectly random.
Implementation
The implementation uses System.nanoTime()
and tracks how many yes decisions occur
across a second window. When the rate is at least 10/s, the yes decisions are equally split over
10 deciseconds, allowing a roll-over of unused yes decisions up until the end of the second.