corvix.observability.tracing

Optional OpenTelemetry tracing for Corvix.

Tracing is opt-in: it requires the otel extra to be installed and CORVIX_OTEL_ENABLED to be truthy. When either is missing, span() is a zero-overhead no-op so call sites never need to branch on availability.

The OTLP exporter honours the standard OTEL_* environment variables (e.g. OTEL_EXPORTER_OTLP_ENDPOINT); only CORVIX_OTEL_ENABLED and an optional service-name override are Corvix-specific.

Attributes

Functions

_truthy(→ bool)

is_enabled(→ bool)

Return whether tracing has been successfully configured.

setup_tracing(→ bool)

Configure the global tracer provider when tracing is requested.

span(→ collections.abc.Iterator[Any])

Start a span as the current context, or no-op when tracing is disabled.

Module Contents

corvix.observability.tracing.logger[source][source]
corvix.observability.tracing._OTEL_AVAILABLE = True[source][source]
corvix.observability.tracing._TRACER_NAME = 'corvix'[source][source]
corvix.observability.tracing._enabled = False[source][source]
corvix.observability.tracing._truthy(value: str | None) bool[source][source]
corvix.observability.tracing.is_enabled() bool[source][source]

Return whether tracing has been successfully configured.

corvix.observability.tracing.setup_tracing(service_name: str | None = None) bool[source][source]

Configure the global tracer provider when tracing is requested.

Returns True when tracing is active afterwards. A no-op (returning False) when CORVIX_OTEL_ENABLED is not truthy or the otel extra is not installed. Safe to call multiple times.

corvix.observability.tracing.span(name: str, attributes: collections.abc.Mapping[str, Any] | None = None) collections.abc.Iterator[Any][source][source]

Start a span as the current context, or no-op when tracing is disabled.

Yields the active span (or None when disabled). Exceptions raised in the block are recorded on the span and re-raised.