Samplers¶
-
class
opencensus.trace.samplers.
AlwaysOffSampler
[source]¶ Bases:
opencensus.trace.samplers.Sampler
Sampler 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.Sampler
Sampler 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.Sampler
Sample 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:
object
Base 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.
-