| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This pull request introduces OpenTelemetry tracing support for gRPC channels in google-api-core. It adds a tracer_provider option to ClientOptions, integrates OpenTelemetry gRPC client interceptors in grpc_helpers.create_channel when tracing is enabled, and safely discards the tracing configuration in async channels to prevent runtime errors. Additionally, dependencies and tests are updated to support this new functionality. The review feedback suggests improving mock hygiene in the newly added tests by patching the local module import path for grpc.secure_channel instead of patching the global module directly, adhering to the repository's style guide.
Sorry, something went wrong.
| mock.patch( | ||
| "grpc.secure_channel", return_value=mock_channel | ||
| ) as mock_secure_channel, |
There was a problem hiding this comment.
According to the Repository Style Guide (Section 4: Unit Testing and Mock Hygiene), we should mock the local module import path instead of patching third-party or global modules directly. This ensures that mocks are isolated and do not leak or cause side effects in other tests.
| mock.patch( | |
| "grpc.secure_channel", return_value=mock_channel | |
| ) as mock_secure_channel, | |
| mock.patch( | |
| "google.api_core.grpc_helpers.grpc.secure_channel", return_value=mock_channel | |
| ) as mock_secure_channel, |
Sorry, something went wrong.
|
|
||
| mock_channel = "raw_channel" | ||
| with ( | ||
| mock.patch("grpc.secure_channel", return_value=mock_channel), |
There was a problem hiding this comment.
According to the Repository Style Guide (Section 4: Unit Testing and Mock Hygiene), we should mock the local module import path instead of patching third-party or global modules directly to ensure proper mock isolation.
| mock.patch("grpc.secure_channel", return_value=mock_channel), | |
| mock.patch("google.api_core.grpc_helpers.grpc.secure_channel", return_value=mock_channel), |
Sorry, something went wrong.
| def mock_secure(*args, **kwargs): | ||
| return grpc.insecure_channel(args[0]) | ||
|
|
||
| monkeypatch.setattr(grpc, "secure_channel", mock_secure) |
There was a problem hiding this comment.
According to the Repository Style Guide (Section 4: Unit Testing and Mock Hygiene), we should mock the local module import path instead of patching third-party or global modules directly to ensure proper mock isolation.
| monkeypatch.setattr(grpc, "secure_channel", mock_secure) | |
| monkeypatch.setattr("google.api_core.grpc_helpers.grpc.secure_channel", mock_secure) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Warning
This description is AI generated and is no longer accurate. NEEDS REVISION.
Problem
Solution
Notes to Reviewers
Expands upon #18069 (Adds additional integration testing to supplement the unit testing)