Please take the OpenCensus user survey


Probabilistic sampler

The probabilistic sampler probabilistically returns True or False for whether a span should be sampled depending on the results of a coin flip.

By default, the probabilistic sampling rate is 1 in 10,000

Code samples

import ""

theSampler = trace.ProbabilitySampler(1/1000.0);
// Samplers are potentially expensive to construct. Use one long-lived
// sampler instead of constructing one for every Span.
static opencensus::trace::ProbabilitySampler sampler(1/1000.0);
const root = new RootSpan(tracer);
const sampler = SamplerBuilder.getSampler(0.01);
const samplerProbability = sampler.shouldSample(root.traceId);


Resource URL
Probability sampler in specs
Go ProbabilitySample trace.ProbabilitySampler
Java ProbabilitySampler trace.ProbabilitySampler
C++ ProbabilitySampler trace.ProbabilitySampler
Node.js TracerConfig trace.TracerConfig