feat(api-core): Opentelemetry tracing support for gRPC transports in google-api-core - #18069
Draft
chalmerlowe wants to merge 9 commits into
Draft
feat(api-core): Opentelemetry tracing support for gRPC transports in google-api-core#18069chalmerlowe wants to merge 9 commits into
chalmerlowe wants to merge 9 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces OpenTelemetry tracing support for gRPC channels. It adds a tracer_provider option to ClientOptions, integrates the OpenTelemetry gRPC client interceptor in grpc_helpers.create_channel when tracing is enabled, and discards the configuration parameter in the async helper to prevent runtime errors. The reviewer identified a critical bug where the code incorrectly attempts to call intercept_channel from the opentelemetry.instrumentation.grpc module instead of the standard grpc module, which would cause a runtime crash. Actionable suggestions and corresponding test updates were provided to resolve this issue.
chalmerlowe
commented
Aug 11, 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
Currently, users of Google Cloud Python client libraries cannot specify a custom OpenTelemetry Tracer Provider for gRPC transports.
Solution
This Pull Request introduces the foundational plumbing in
google-api-coreto support custom tracer providers for gRPC transports.tracer_provideras a recognized parameter inClientOptions.grpc_helpers.create_channelto extract thetracer_providerfrom the configuration (supporting both dictionary and object formats) and pass it to the OpenTelemetry gRPC client interceptor.grpc_helpers_async.create_channelto safely discard theconfigurationparameter. This preventsTypeErrorwhen generated async code passes it down, ensuring generated code does not fail even though async tracing is deferred to a future phase of this project.Notes to Reviewers
grpc_helpers.pycontinues to fail open. If theopentelemetry-instrumentation-grpcpackage is not installed, tracing is skipped quietly without failing the transport creation.grpc_helpers_async.pyare strictly defensive to prevent runtime errors when generated code tries to pass configuration down.