Samplers¶
-
class
opencensus.trace.samplers.AlwaysOffSampler[source]¶ Bases:
opencensus.trace.samplers.SamplerSampler that doesn't sample any request, regardless of trace options.
-
should_sample(span_context)[source]¶ Whether to sample this request.
- Parameters
span_context (
opencensus.trace.span_context.SpanContext) -- The span context.- Return type
bool
- Returns
Whether to sample the request according to the context.
-
-
class
opencensus.trace.samplers.AlwaysOnSampler[source]¶ Bases:
opencensus.trace.samplers.SamplerSampler that samples every request, regardless of trace options.
-
should_sample(span_context)[source]¶ Whether to sample this request.
- Parameters
span_context (
opencensus.trace.span_context.SpanContext) -- The span context.- Return type
bool
- Returns
Whether to sample the request according to the context.
-
-
class
opencensus.trace.samplers.ProbabilitySampler(rate=None)[source]¶ Bases:
opencensus.trace.samplers.SamplerSample a request at a fixed rate.
- Parameters
rate (float) -- The rate of sampling.
-
should_sample(span_context)[source]¶ Make the sampling decision based on the lower 8 bytes of the trace ID. If the value is less than the bound, return True, else False.
- Parameters
span_context (
opencensus.trace.span_context.SpanContext) -- The span context.- Return type
bool
- Returns
Whether to sample the request according to the context.
-
class
opencensus.trace.samplers.Sampler[source]¶ Bases:
objectBase class for opencensus trace request samplers.
Subclasses must override
should_sample().-
should_sample(span_context)[source]¶ Whether to sample this request.
- Parameters
span_context (
opencensus.trace.span_context.SpanContext) -- The span context.- Return type
bool
- Returns
Whether to sample the request according to the context.
-