Skip to content
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

Merged

Conversation

jade-guiton-dd
Copy link
Contributor

@jade-guiton-dd jade-guiton-dd commented Feb 7, 2025

Description

This PR uses the grpc.WithUnaryInterceptor option to add the metadata configured in ClientConfig.Headers automatically to requests made with the created grpc.ClientConn. Currently, users of configgrpc 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.

@jade-guiton-dd jade-guiton-dd force-pushed the configgrpc-metadata-interceptor branch from 8b5deaf to e65b511 Compare February 7, 2025 14:06
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.38%. Comparing base (765e4a5) to head (27f487f).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
config/configgrpc/configgrpc.go 82.35% 3 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

@jade-guiton-dd jade-guiton-dd marked this pull request as ready for review February 10, 2025 10:24
@jade-guiton-dd jade-guiton-dd requested a review from a team as a code owner February 10, 2025 10:24
@mx-psi mx-psi enabled auto-merge February 10, 2025 11:42
@mx-psi mx-psi added this pull request to the merge queue Feb 10, 2025
Merged via the queue into open-telemetry:main with commit bbf8ee3 Feb 10, 2025
50 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[configgrpc] Handle gRPC metadata generically
2 participants