feat(sdk): add otel=True instrumentation flag for Python SDK#117
Merged
Conversation
Adds opt-in OpenTelemetry gRPC instrumentation to ConfigClient and AsyncConfigClient. When otel=True, an OTel interceptor is wired outermost on the channel so get/set/watch RPCs appear in application traces. - New _otel.py module with lazy imports (no dep cost when otel=False) - otel optional extra: pip install opendecree[otel] - Works for sync client, async client, and watchers (inherit channel) - OTel interceptor is outermost (wraps user interceptors + auth) - 100% test coverage; 10 new unit tests Co-Authored-By: Claude <noreply@anthropic.com> Closes #23
3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
_otel.pymodule lazy-importsopentelemetry-instrumentation-grpc, so importing the SDK does not pull in OTel unlessotel=Trueis passed.Test plan
make test— 298 passed, 100% coverage (10 new unit tests intest_otel.py)make lint— clean (ruff check + format)test_otel.py::TestMakeSyncInterceptor— verifies lazy import, helpful error on missing packagetest_otel.py::TestMakeAioInterceptors— same for asynctest_otel.py::TestSyncClientOtel— verifies interceptor ordering (OTel → user → auth)test_otel.py::TestAsyncClientOtel— same for async clientCloses #23