viam.rpc.tracing

Automated OpenTelemetry tracing for gRPC RPCs in the Viam Python SDK.

Tracing is an optional feature. Install the tracing extra to enable it:

pip install "viam-sdk[tracing]"

Without the extra, every function in this module is a safe no-op so the rest of the SDK works unchanged. With the extra, spans are emitted only when the VIAM_MODULE_TRACING environment variable is set to a truthy value, mirroring viam-cpp-sdk.

When enabled, the W3C Trace Context propagator is installed so incoming trace context is honored, and a custom exporter ships spans to the parent viam-server via the RobotService.SendTraces RPC.

OTLP encoding is implemented locally against the protobuf types bundled under viam.gen.opentelemetry so that the SDK does not depend on the PyPI opentelemetry-proto package, which would conflict with those bundled types in the protobuf descriptor pool.

Attributes

LOGGER

TRACING_ENV_VAR

INSTRUMENTATION_SCOPE

SERVICE_NAME_VALUE

OTEL_AVAILABLE

Functions

tracing_enabled(→ bool)

Return whether tracing is enabled via the VIAM_MODULE_TRACING env var.

Module Contents

viam.rpc.tracing.LOGGER
viam.rpc.tracing.TRACING_ENV_VAR = 'VIAM_MODULE_TRACING'
viam.rpc.tracing.INSTRUMENTATION_SCOPE = 'viam-python-sdk'
viam.rpc.tracing.SERVICE_NAME_VALUE = 'viam-python-sdk'
viam.rpc.tracing.OTEL_AVAILABLE = True
viam.rpc.tracing.tracing_enabled() bool[source]

Return whether tracing is enabled via the VIAM_MODULE_TRACING env var.

Returns False when the tracing extra is not installed, warning once if the env var is set but the extra is missing.