How to use the opentelemetry-api.src.opentelemetry.trace.sampling.StaticSampler function in opentelemetry-api

To help you get started, we’ve selected a few opentelemetry-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-telemetry / opentelemetry-python / opentelemetry-api / src / opentelemetry / trace / sampling.py View on Github external
parent_context: Optional["SpanContext"],
        trace_id: int,
        span_id: int,
        name: str,
        attributes: Optional[Attributes] = None,  # TODO
        links: Sequence["Link"] = (),
    ) -> "Decision":
        if parent_context is not None:
            return Decision(parent_context.trace_options.sampled)

        return Decision(trace_id & self.CHECK_BYTES < self.bound)


# Samplers that ignore the parent sampling decision and never/always sample.
ALWAYS_OFF = StaticSampler(Decision(False))
ALWAYS_ON = StaticSampler(Decision(True))

# Samplers that respect the parent sampling decision, but otherwise
# never/always sample.
DEFAULT_OFF = ProbabilitySampler(0.0)
DEFAULT_ON = ProbabilitySampler(1.0)
github open-telemetry / opentelemetry-python / opentelemetry-api / src / opentelemetry / trace / sampling.py View on Github external
self,
        parent_context: Optional["SpanContext"],
        trace_id: int,
        span_id: int,
        name: str,
        attributes: Optional[Attributes] = None,  # TODO
        links: Sequence["Link"] = (),
    ) -> "Decision":
        if parent_context is not None:
            return Decision(parent_context.trace_options.sampled)

        return Decision(trace_id & self.CHECK_BYTES < self.bound)


# Samplers that ignore the parent sampling decision and never/always sample.
ALWAYS_OFF = StaticSampler(Decision(False))
ALWAYS_ON = StaticSampler(Decision(True))

# Samplers that respect the parent sampling decision, but otherwise
# never/always sample.
DEFAULT_OFF = ProbabilitySampler(0.0)
DEFAULT_ON = ProbabilitySampler(1.0)

opentelemetry-api

OpenTelemetry Python API

Apache-2.0
Latest version published 14 days ago

Package Health Score

97 / 100
Full package analysis