Skip to content

opentelemetry-exporter-otlp-proto-grpc breaks with protobuf 4.21.0  #2717

@tl-moreno-vendra

Description

@tl-moreno-vendra

opentelemetry-exporter-otlp-proto-grpc is broken on its latest stable release (v1.11.1). This is due to the breaking changes contained in the latest release of protobuf. You can find more details about the breaking changes here: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Describe your environment

  • Python version: 3.9.10
  • opentelemetry-exporter-otlp-proto-grpc version: v1.11.1

Steps to reproduce

from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter

What is the expected behavior?
The OTLPSpanExporter is imported correctly.

What is the actual behavior?
This exception is thrown:

Traceback (most recent call last):
  File "/Users/vendra/Projects/tl/tmp/python-otel/protobuf_issue.py", line 1, in <module>
    from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
  File "/Users/vendra/Library/Caches/pypoetry/virtualenvs/python-otel-issue-demo-UdOd2j3B-py3.9/lib/python3.9/site-packages/opentelemetry/exporter/otlp/proto/grpc/trace_exporter/__init__.py", line 22, in <module>
    from opentelemetry.exporter.otlp.proto.grpc.exporter import (
  File "/Users/vendra/Library/Caches/pypoetry/virtualenvs/python-otel-issue-demo-UdOd2j3B-py3.9/lib/python3.9/site-packages/opentelemetry/exporter/otlp/proto/grpc/exporter.py", line 39, in <module>
    from opentelemetry.proto.common.v1.common_pb2 import (
  File "/Users/vendra/Library/Caches/pypoetry/virtualenvs/python-otel-issue-demo-UdOd2j3B-py3.9/lib/python3.9/site-packages/opentelemetry/proto/common/v1/common_pb2.py", line 36, in <module>
    _descriptor.FieldDescriptor(
  File "/Users/vendra/Library/Caches/pypoetry/virtualenvs/python-otel-issue-demo-UdOd2j3B-py3.9/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Additional context
More context about the issue and the latest protobuf release can be found here:
https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions