fix: lazy per-protocol OTLP exporter imports so unused transports can't break the SDK - #2
Merged
Merged
Conversation
…'t break the SDK A drifted opentelemetry-exporter-otlp-proto-grpc install (1.40.0 against opentelemetry-sdk 1.25.0) made the module-level gRPC exporter imports in client.py raise ImportError, taking down the whole package for http/protobuf users who never touch gRPC. Following the OTEL-distro pattern: - import exporters lazily at init time, scoped to the configured protocol - raise an actionable ImportError (names the drift, reinstall command, installed opentelemetry-* versions) when the needed transport is broken - move the gRPC exporter to an optional [grpc] extra; add <2.0 bounds - add regression tests that poison the gRPC modules and assert the package imports, HTTP tracing works, and grpc users get a clear error
….2.0 - dev extra now installs opentelemetry-exporter-otlp-proto-grpc since the test suite mock.patches the gRPC transport (clean 'pip install -e .[dev]' previously broke the gRPC tests) - README: drop the stale 'both protocols included in all installations' claim, document the [grpc] extra in Installation and the gRPC protocol section - bump version to 0.2.0 for the breaking [grpc]-extra change
haohuaijin
approved these changes
Jul 28, 2026
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.
Problem
A version-drifted
opentelemetry-exporter-otlp-proto-grpcinstall (1.40.0 alongsideopentelemetry-sdk1.25.0) made the module-level gRPC exporter imports inclient.pyraiseImportError— taking down the entire package, including forhttp/protobufusers who never touch gRPC. In a fail-open consumer (the Claude Code tracing hook) this silently disabled reporting for two months.Version pins alone can't prevent this: the OTLP exporters already declare
opentelemetry-sdk~=1.xlockstep, yetpip install --userpaths can still bypass resolver guarantees.Fix (OTEL-distro / dd-trace-py pattern)
client.pyno longer imports any OTLP exporter at module top. Eachinitialize_*imports only the configured protocol's exporter at init time — a broken transport you don't use can never break you.ImportErrornames the likely version drift, gives the reinstall command, and lists every installedopentelemetry-*version.pip install openobserve-telemetry-sdk[grpc](matches Splunk/Honeycomb OTEL distros; also drops the heavygrpciochain from core installs). All OTEL deps get<2.0upper bounds.tests/test_broken_transport.pypoisons the gRPC exporter modules and asserts the package still imports, HTTP tracing still initializes, and gRPC users get a clear error pointing at the[grpc]extra.Breaking change
protocol="grpc"users must now install the[grpc]extra. HTTP users (the default) are unaffected.Testing
python -m pytest tests/)