public abstract class CollectorSampler extends Object
Debug
spans are always stored.
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
.
Modifier and Type | Field and Description |
---|---|
static CollectorSampler |
ALWAYS_SAMPLE |
Modifier | Constructor and Description |
---|---|
protected |
CollectorSampler() |
Modifier and Type | Method and Description |
---|---|
protected abstract long |
boundary() |
static CollectorSampler |
create(float rate) |
boolean |
isSampled(String hexTraceId,
boolean debug)
Returns true if spans with this trace ID should be recorded to storage.
|
String |
toString() |
public static final CollectorSampler ALWAYS_SAMPLE
public static CollectorSampler create(float rate)
rate
- minimum sample rate is 0.0001, or 0.01% of tracesprotected abstract long boundary()
public boolean isSampled(String hexTraceId, boolean debug)
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.
hexTraceId
- the lower 64 bits of the span's trace ID are checked against the boundarydebug
- when true, always passes samplingCopyright © 2015–2018 OpenZipkin. All rights reserved.