Allow user use custom grpc::ChannelArguments#3990
Allow user use custom grpc::ChannelArguments#3990owent wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the OTLP gRPC exporter/client configuration to allow callers to supply custom grpc::ChannelArguments, enabling advanced gRPC tuning (e.g., disabling HTTP proxy handling to avoid getenv-related races) while preserving existing option-derived defaults.
Changes:
- Add
channel_argumentstoOtlpGrpcClientOptionsand copy caller-provided arguments into the channel configuration. - Refactor channel-argument construction into
OtlpGrpcClient::BuildChannelArguments()and reuse it fromMakeChannel(). - Add a unit test validating that caller-provided channel arguments are copied and that user-agent configuration is applied.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h | Adds a new options field for passing custom gRPC channel arguments. |
| exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h | Adds an internal helper for building channel arguments (used by implementation + tests). |
| exporters/otlp/src/otlp_grpc_client.cc | Implements copying of caller-provided channel arguments and refactors channel argument construction. |
| exporters/otlp/test/otlp_grpc_target_test.cc | Adds coverage to verify channel-argument copying and user-agent behavior. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3990 +/- ##
==========================================
+ Coverage 90.32% 90.33% +0.02%
==========================================
Files 230 230
Lines 7299 7299
==========================================
+ Hits 6592 6593 +1
+ Misses 707 706 -1 🚀 New features to boost your workflow:
|
1daae04 to
714b895
Compare
714b895 to
cc58164
Compare
| void OtlpGrpcClient::PopulateChannelArguments(const OtlpGrpcClientOptions &options, | ||
| grpc::ChannelArguments &grpc_arguments) | ||
| { | ||
| grpc_arguments = grpc::ChannelArguments{}; |
There was a problem hiding this comment.
This seems redundant because it is already default initialized.
| * This is a non-owning pointer, and the pointed-to arguments are copied when the channel is | ||
| * created. | ||
| */ | ||
| const grpc::ChannelArguments *channel_arguments{}; |
There was a problem hiding this comment.
nit - Question: can we make the lifetime requirement a bit more explicit here? Something like:
/*
This is a non-owning pointer; the pointed-to grpc::ChannelArguments must remain valid until client/channel construction copies it.
*/Currently, "Copied when the channel is created" is directionally right, but it still leaves the required lifetime a little ambiguous.
Fixes #3883
Changes
grpc::ChannelArgumentswith SDK.For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes