OpenTelemetry Python Proto

raw JSON →
1.40.0 verified Tue May 12 auth: no python install: stale quickstart: stale

OpenTelemetry is a set of APIs, libraries, agents, and instrumentation to provide observability for applications. Current version is 1.40.0, with releases following a regular cadence for improvements and bug fixes.

pip install opentelemetry-proto
error ImportError: cannot import name 'descriptor' from 'google.protobuf' OR TypeError: Descriptors cannot not be created directly
cause These errors typically occur due to a version conflict between the `protobuf` library and the `opentelemetry-proto` package or other OpenTelemetry components that rely on specific `protobuf` versions.
fix
Ensure that your protobuf installation is compatible with your OpenTelemetry packages. A common fix is to install a specific range, e.g., pip install "protobuf>=3.19,<5.0" or check the opentelemetry-proto package requirements via pip show opentelemetry-proto | grep Requires and install a compatible protobuf version.
error ModuleNotFoundError: No module named 'opentelemetry.exporter.otlp.proto.grpc.metric_exporter'
cause This `ModuleNotFoundError` indicates that the required OpenTelemetry exporter package, or a specific module within it, is either not installed, installed in an incorrect Python environment, or there's a version mismatch among OpenTelemetry SDK components.
fix
Ensure all necessary OpenTelemetry packages are installed in the active virtual environment using pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp opentelemetry-exporter-otlp-proto-grpc opentelemetry-proto. It's also recommended to use opentelemetry-bootstrap -a install for auto-detection and installation of instrumentations.
error AttributeError: module 'opentelemetry.sdk.trace' has no attribute 'SpanLimits'
cause This `AttributeError` points to an incompatibility or version mismatch between different OpenTelemetry Python packages, where one package expects a class or function (like `SpanLimits`) that exists in a different version of another package.
fix
The most effective fix is to ensure all OpenTelemetry packages are at compatible versions. Use pip list | grep opentelemetry to check installed versions and consider pinning them to known compatible sets or performing a clean reinstall of all OpenTelemetry-related packages.
error ImportError: cannot import name 'InstrumentationScope' from 'opentelemetry.proto.common.v1.common_pb2'
cause This error occurs when there's an issue with the Python-generated code from OpenTelemetry's Protocol Buffer definitions, usually due to conflicting installations of `opentelemetry-proto` or other packages that generate protobuf code, leading to an inability to correctly import components like `InstrumentationScope` from the expected module.
fix
This often resolves by reinstalling opentelemetry-proto or ensuring that no other packages are shadowing the expected opentelemetry.proto imports. Verify environment consistency and ensure opentelemetry-proto is correctly installed.
breaking start_span and start_as_current_span return behavior has changed.
fix Review the new behavior of NoOpTracer and update your span logic accordingly.
deprecated LoggingHandler in opentelemetry-sdk is deprecated; use opentelemetry-instrumentation-logging instead.
fix Switch to using opentelemetry-instrumentation-logging for logging.
breaking The module `opentelemetry.proto.tracing` is an internal module and not intended for direct import. It has been removed or is inaccessible through standard library imports.
fix Avoid importing from `opentelemetry.proto`. If you were trying to access `NoOpTracer`, import it from `opentelemetry.trace` instead (e.g., `from opentelemetry.trace import NoOpTracer`).
breaking `opentelemetry.proto.tracing` module has been removed or refactored. Direct imports from this path will now result in a `ModuleNotFoundError`.
fix Update imports to use the correct location for `NoOpTracer` (e.g., `from opentelemetry.sdk.trace import NoOpTracer`) or remove references to the internal `proto` modules.
python os / libc status wheel install import disk
3.10 alpine (musl) - - - -
3.10 slim (glibc) - - - -
3.11 alpine (musl) - - - -
3.11 slim (glibc) - - - -
3.12 alpine (musl) - - - -
3.12 slim (glibc) - - - -
3.13 alpine (musl) - - - -
3.13 slim (glibc) - - - -
3.9 alpine (musl) - - - -
3.9 slim (glibc) - - - -

A simple example of using NoOpTracer to create a span.

from opentelemetry.proto.tracing import NoOpTracer
tracer = NoOpTracer()
span = tracer.start_span('example')