Package zipkin2.collector
Class CollectorSampler
java.lang.Object
zipkin2.collector.CollectorSampler
CollectorSampler decides if a particular trace should be "sampled", i.e. recorded in permanent
storage. This involves a consistent decision based on the span's trace ID with one notable
exception:
Debug
spans are always stored.
Implementation
Accepts a percentage of trace ids by comparing their absolute value against a potentially
dynamic boundary. eg isSampled == abs(traceId) <= boundary
While idempotent, this implementation's sample rate won't exactly match the input rate because
trace ids are not perfectly distributed across 64bits. For example, tests have shown an error
rate of 3% when 100K trace ids are random
.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract long
boundary()
static CollectorSampler
create
(float rate) Returns a trace ID sampler with the indicated rate.boolean
Returns true if spans with this trace ID should be recorded to storage.toString()
-
Field Details
-
ALWAYS_SAMPLE
-
-
Constructor Details
-
CollectorSampler
protected CollectorSampler()
-
-
Method Details
-
create
Returns a trace ID sampler with the indicated rate.- Parameters:
rate
- minimum sample rate is 0.0001, or 0.01% of traces
-
boundary
protected abstract long boundary() -
isSampled
Returns true if spans with this trace ID should be recorded to storage.Zipkin v1 allows storage-layer sampling, which can help prevent spikes in traffic from overloading the system. Debug spans are always stored.
This uses only the lower 64 bits of the trace ID as instrumentation still send mixed trace ID width.
- Parameters:
hexTraceId
- the lower 64 bits of the span's trace ID are checked against the boundarydebug
- when true, always passes sampling
-
toString
-