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
Add HTTP headers support to common HTTP client. #416
Conversation
27796f3
to
49aba83
Compare
Mailing list discussion: https://groups.google.com/g/prometheus-developers/c/p9HTlPzwUEo |
Wondering if this will enable what was intended in #326 |
a7c7b9d
to
bb90569
Compare
config/headers.go
Outdated
Headers map[string][]string `yaml:"headers,omitempty" json:"headers,omitempty"` | ||
SecretHeaders map[string][]Secret `yaml:"secret_headers,omitempty" json:"secret_headers,omitempty"` | ||
Files map[string][]string `yaml:"files,omitempty" json:"files,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this entire scheme a bit confusing, both in the non-uniformity of the names (we have normal headers, secret headers, and then just files, which I understand why can't be file headers but still), and also in the names themselves (secret headers could be interpreted as intended, a header with a secret value, or some sort of a "secret" header). Of course they'll be docs to clear this up but I still think it's less than ideal. Therefore, I propose we instead have an iterated:
type header struct {
name/key string
value string
secret secret
file string
}
Which I think would be more clear and also allow for more complicated header appends. Generally a small difference though so feel free to ignore.
config/headers.go
Outdated
if _, ok := reservedHeaders[http.CanonicalHeaderKey(k)]; ok { | ||
return fmt.Errorf("setting header %q is not allowed", http.CanonicalHeaderKey(k)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make more sense for this check to come first
@roidelapluie @LeviHarrison what is status in this PR? At least I am interested of this feature |
Me too! Adding headers to requests is a relatively trivial operation and multiple APIs support that |
Just some small revisions @roidelapluie friendly ping |
This is named `http_headers` so it does not clash with blackbox exporter's headers and Prometheus remote client's headers, which are simple maps. Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
@LeviHarrison here you go 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
As usual we'll need to update Prom docs after this
This is named
http_headers
so it does not clash with blackbox exporter's headers and Prometheus remote client's headers, which are simple maps.Signed-off-by: Julien Pivotto roidelapluie@o11y.eu