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
Datasource: Add custom headers on alerting queries #19508
Datasource: Add custom headers on alerting queries #19508
Conversation
Reference issue grafana#15381 Signed-off-by: Martin Schneppenheim <martin.schneppenheim@rewe-digital.com>
@weeco thanks. First of all you have some linting errors:
Then you have some nil-pointer errors: https://circleci.com/gh/grafana/grafana/159848?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-checks-link |
@marefr Exactly I meant these linting errors and I am not sure how you want me to handle these. Since I return the What do you recommend here? I'll take a look at the failing test in the meantime. |
Oh right. I think you have to return something else than type cachedTransport struct {
updated time.Time
*dataSourceTransport
}
type dataSourceTransport struct {
roundTripper http.RoundTripper
transport *http.Transport
}
...
func (ds *DataSource) GetHttpTransport() (*dataSourceTransport, error) {
...
// RoundTrip implements http.RoundTripper.
func (dst *dataSourceTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return dst.roundTripper.RoundTrip(req)
} |
@marefr I think you can give this another look now. |
Any update? |
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.
Sorry it took some time for me to get back to this. Great work 👍 Some test-related changes left before we can merge to make sure that we have some additional test-coverage for the future in case we change/put in additional logic around round trippers. See comment for detail.
Have verified that it's working as expected using Prometheus:
Have verified that it's working as expected using Elasticsearch:
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.
Perfect 👍 Great work!
@weeco Thank you for contributing to Grafana! |
Reference issue #15381
Which issue(s) this PR fixes:
Fixes #15381
I am not sure whether this pull request fixes the problem for all datasources, but it does fix the Problem for the Prometheus datasource. Thus I have omitted the keyword which automatically closes the referenced issue.
Special notes for your reviewer:
This PR does not add any further tests, as I wasn't sure how I can implement the tests for the custom headers. Additionally this breaks the existing
datasource_cache.test
as it is testing the TLS configuration.What's the best way to handle this? Maintainers' changes obviously welcome.