Skip to content

Pure-Python otlp-proto-grpc (drop protobuf + grpcio) [4/4 RFC] - #5506

Draft
ocelotl wants to merge 5 commits into
open-telemetry:mainfrom
ocelotl:pure-python-otlp-4-grpc
Draft

Pure-Python otlp-proto-grpc (drop protobuf + grpcio) [4/4 RFC]#5506
ocelotl wants to merge 5 commits into
open-telemetry:mainfrom
ocelotl:pure-python-otlp-4-grpc

Conversation

@ocelotl

@ocelotl ocelotl commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What

Replace the opentelemetry-exporter-otlp-proto-grpc transport with a pure-Python implementation that:

Also drops googleapis-common-protos and the gcp-auth optional extra (a requests.Session-typed credential provider, incompatible with a non-requests stack).

Why drop grpcio

grpcio is a large compiled native dependency and one of the most common source-build / wheel-availability pain points in the ecosystem (new Python versions, musl/arm/exotic platforms, version pinning). A pure-Python gRPC-over-HTTP/2 transport removes that native dependency for the OTLP/gRPC exporter.

Stacked series (merge in order)

  1. opentelemetry-proto → pure-Python
  2. opentelemetry-exporter-otlp-proto-common → pure-Python backend
  3. opentelemetry-exporter-otlp-proto-http → pure-Python + urllib
  4. opentelemetry-exporter-otlp-proto-grpc → pure-Python gRPC (this PR)

Depends on #5503#5505; diff is cumulative. Isolated per-package diff:
https://github.com/ocelotl/opentelemetry-python/compare/pure-python-otlp-3-http...pure-python-otlp-4-grpc

Discussion points (why this is a draft)

  • Maturity of _pygrpc. A hand-written gRPC/HTTP-2 transport is a meaningful surface to own; performance, flow-control, keepalive, and error-mapping vs grpcio all deserve scrutiny before this could be a default.
  • Entry-point names (otlp_proto_grpc) are unchanged. Existing tests need adaptation; CI not expected green while the stack is in flight. See Pure-Python opentelemetry-proto (drop the protobuf dependency) [1/4 RFC] #5503 for the full rationale.

Stack (merge in order): #5503 (proto) → #5504 (common) → #5505 (http) → #5506 (grpc)

ocelotl added 3 commits August 2, 2026 21:33
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).
Point the shared OTLP encoders at the pure-Python opentelemetry-proto package.
No google.protobuf dependency; public opentelemetry.exporter.otlp.proto.common.*
API preserved via re-export shims over the private _proto implementation.
Drop the requests dependency in favour of stdlib urllib.request + ssl for the
OTLP/HTTP export, and use the pure-Python protobuf encoders. Removes both the
protobuf and requests native/third-party dependencies. The requests.Session
credential-provider feature (session= arg and *_CREDENTIAL_PROVIDER env vars,
plus the gcp-auth extra) is not carried over, as it is typed to requests.Session.
ocelotl added 2 commits August 2, 2026 22:13
…no requests)

Reinstates the original exporter's pluggable-client capability without a
`requests` dependency:

- A `urllib.request.OpenerDirector` is now the supported injectable, via the
  `session` constructor argument or an `opentelemetry_otlp_credential_provider`
  entry point named by the existing
  OTEL_PYTHON_EXPORTER_OTLP_HTTP[_TRACES|_METRICS|_LOGS]_CREDENTIAL_PROVIDER
  environment variables (previously loaded but never wired in).
- A `requests.Session` is still accepted for backwards compatibility, detected
  structurally (never importing `requests`) and routed through its `.post()`;
  passing one now emits a DeprecationWarning. Its transport errors are
  normalized to URLError so the retry loop is unchanged.
- Default (no injection) builds a stdlib opener from the SSL context, matching
  prior behavior.

`_common` gains `_resolve_client` (the client seam) and `_opener_client` /
`_session_client` senders; `_load_session_from_envvar` becomes
`_load_provider_from_envvar`. The three HTTP credential-provider docstrings in
opentelemetry-sdk are updated to document the OpenerDirector contract and the
requests.Session deprecation. Drops the moot pyproto-vs-requests equivalence
test and covers the new client-resolution paths.
Drop the grpcio dependency in favour of a pure-Python gRPC-over-HTTP/2 transport
(_pygrpc) and the pure-Python protobuf encoders. Removes both the protobuf and
grpcio native dependencies from the OTLP/gRPC exporter.
@ocelotl
ocelotl force-pushed the pure-python-otlp-4-grpc branch from 785406e to e536536 Compare August 3, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant