-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[configgrpc] Insert headers automatically #12320
[configgrpc] Insert headers automatically #12320
Conversation
8b5deaf
to
e65b511
Compare
Codecov ReportAttention: Patch coverage is
❌ Your patch status has failed because the patch coverage (85.71%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #12320 +/- ##
==========================================
- Coverage 91.39% 91.38% -0.02%
==========================================
Files 468 468
Lines 25591 25610 +19
==========================================
+ Hits 23390 23404 +14
- Misses 1785 1790 +5
Partials 416 416 ☔ View full report in Codecov by Sentry. |
bbf8ee3
Description
This PR uses the
grpc.WithUnaryInterceptor
option to add the metadata configured inClientConfig.Headers
automatically to requests made with the createdgrpc.ClientConn
. Currently, users ofconfiggrpc
must extract the headers from the config and insert them manually in each request.The current implementation is meant to be backward-compatible with code that manually inserts the headers: if a header key is already present in the
Context
passed to the interceptor, it will not be modified and no duplicate will be added.Link to tracking issue
Fixes #12307
Testing
The tests in
otlpexporter
check that headers are properly inserted, and they still pass after removing the OTLP-specific headers code. I also added a new test in configgrpc for testing unary RPC calls.I'm not sure how to easily test streaming RPC calls however (hence the lacking code coverage), but since the docs imply that adding metadata to streaming RPC calls is the same as unary calls, it should hopefully work.