Pure-Python opentelemetry-proto (drop the protobuf dependency) [1/4 RFC] - #5503
Draft
ocelotl wants to merge 1 commit into
Draft
Pure-Python opentelemetry-proto (drop the protobuf dependency) [1/4 RFC]#5503ocelotl wants to merge 1 commit into
ocelotl wants to merge 1 commit into
Conversation
Swap the google.protobuf-generated message classes for hand-written pure-Python encoders under opentelemetry._proto, keeping the public opentelemetry.proto.* import namespace via thin re-export shims. Removes the protobuf (and native upb) dependency entirely; only the serialize path used by the OTLP exporters is implemented (plus the empty export-service response decode).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replace the
google.protobuf-generated message classes inopentelemetry-protowith a hand-written pure-Python protobuf implementation, and drop theprotobufdependency (protobuf>=5.0, <8.0) entirely.The public
opentelemetry.proto.*import namespace is preserved: real code lives under a privateopentelemetry._protopackage, and the existingopentelemetry.proto.*modules become thin re-export shims (from opentelemetry._proto... import *). Downstream code importingopentelemetry.proto.trace.v1.trace_pb2etc. keeps working unchanged.Why
protobufships a compiled C extension (upb) and enforces a narrow, moving version range. That causes real friction:protobufcan collide with the version the target app pins, producing hard-to-diagnose ABI/version errors. A pure-Python encoder is safe to inject.>=5.0,<8.0range regularly clashes with other libraries (gRPC stacks, ML tooling, cloud SDKs).The OTLP exporters only ever serialize protobuf; they never parse arbitrary messages. The only decode needed is the export-service response, which is empty. So a small, auditable encode-only implementation is sufficient — this is not a general-purpose protobuf runtime.
Scope of this PR
This is the base of a 4-PR stacked series that makes the whole OTLP export path dependency-light. Merge order:
opentelemetry-proto→ pure-Python (this PR)opentelemetry-exporter-otlp-proto-common→ pure-Python backendopentelemetry-exporter-otlp-proto-http→ pure-Python + stdliburllib(dropsrequests)opentelemetry-exporter-otlp-proto-grpc→ pure-Python gRPC (dropsgrpcio)Because this org's fork model can't host intermediate base branches upstream, each PR targets
mainand its diff is cumulative (this PR's changes appear in all four). Isolated per-package diffs are viewable via the fork compare links noted in PRs 2–4.Known gaps / discussion points (why this is a draft)
profilessignal not ported. The pure-Python impl currently coverscommon,resource,trace,metrics,logsand the collector service messages, but notopentelemetry.proto.profiles. That namespace is removed here and would need to be added before this could replace the current package for profiles users..protosources the project vendors, so schema changes stay mechanical. This PR carries a hand-written implementation; agreeing on a generator is part of the discussion._proto(real) +proto(shim) split is one option; collapsing intoprotodirectly is another. Happy to go either way.protobuf-generated serialization; a differential test against the current encoders would be worth adding.The reference implementation this is derived from has been running in a downstream distribution.
Stack (merge in order): #5503 (proto) → #5504 (common) → #5505 (http) → #5506 (grpc)