config: change NewOAuth2RoundTripper to accept variadic HTTPClientOption#898
Merged
roidelapluie merged 1 commit intoprometheus:mainfrom Apr 15, 2026
Conversation
The fourth parameter was *httpClientOptions, an unexported type, making NewOAuth2RoundTripper effectively uncallable with a non-nil options argument from any package outside prometheus/common/config. Callers were forced to resort to reflection or unsafe pointer tricks. Change the signature to accept variadic ...HTTPClientOption — the existing exported interface — matching the pattern already used by NewRoundTripperFromConfigWithContext. The function builds its own httpClientOptions copy from the supplied options, starting from defaultHTTPClientOptions. The single internal call site is updated to pass optFuncs... instead of &opts; tests that passed &defaultHTTPClientOptions now pass no options (equivalent behaviour, defaultHTTPClientOptions is the zero value). Fixes prometheus/prometheus#18329 Signed-off-by: Ali <alliasgher123@gmail.com>
roidelapluie
approved these changes
Apr 15, 2026
Member
|
Thanks! |
2 tasks
korniltsev-grafanista-yolo-vibecoder239
added a commit
to korniltsev-grafanista-yolo-vibecoder239/alloy
that referenced
this pull request
Apr 15, 2026
…ripper prometheus/common#898 changed NewOAuth2RoundTripper to accept variadic HTTPClientOption instead of the unexported *httpClientOptions, making the reflection+unsafe workaround unnecessary. Bump prometheus/common to include the fix and call the upstream function directly, converting local options via a new toUpstreamOpts helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
NewOAuth2RoundTripperpreviously accepted*httpClientOptionsas its fourthparameter — an unexported type. This made the function effectively
uncallable with a non-nil options argument from any package outside
prometheus/common/config, forcing downstream users (e.g. Grafana Alloy) toresort to reflection or
unsafepointer tricks.Reported upstream in prometheus/prometheus#18329.
Change
Replace the unexported
*httpClientOptionsparameter with variadic...HTTPClientOption— the exported interface already used byNewRoundTripperFromConfigWithContext:Internally the function builds its own
httpClientOptionscopy from the supplied options starting fromdefaultHTTPClientOptions, so behaviour is identical to before when no options are passed.Call sites updated
NewRoundTripperFromConfigWithContext: passesoptFuncs...instead of&opts&defaultHTTPClientOptionsnow pass no options (equivalent — defaults are unchanged)Tests