mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
Pass HTTP transport to the proxy
When we proxy requests we should use same transport as we use when collecting alerts & silences
This commit is contained in:
@@ -40,7 +40,7 @@ type Alertmanager struct {
|
||||
reader uri.Reader
|
||||
// implements how we fetch requests from the Alertmanager, we don't set it
|
||||
// by default so it's nil and http.DefaultTransport is used
|
||||
httpTransport http.RoundTripper
|
||||
HTTPTransport http.RoundTripper `json:"-"`
|
||||
// lock protects data access while updating
|
||||
lock sync.RWMutex
|
||||
// fields for storing pulled data
|
||||
|
||||
@@ -46,7 +46,7 @@ func NewAlertmanager(name, upstreamURI string, opts ...Option) (*Alertmanager, e
|
||||
}
|
||||
|
||||
var err error
|
||||
am.reader, err = uri.NewReader(am.URI, am.RequestTimeout, am.httpTransport)
|
||||
am.reader, err = uri.NewReader(am.URI, am.RequestTimeout, am.HTTPTransport)
|
||||
if err != nil {
|
||||
return am, err
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func WithRequestTimeout(timeout time.Duration) Option {
|
||||
// a custom HTTP transport (http.RoundTripper implementation)
|
||||
func WithHTTPTransport(httpTransport http.RoundTripper) Option {
|
||||
return func(am *Alertmanager) error {
|
||||
am.httpTransport = httpTransport
|
||||
am.HTTPTransport = httpTransport
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
1
proxy.go
1
proxy.go
@@ -37,6 +37,7 @@ func NewAlertmanagerProxy(alertmanager *alertmanager.Alertmanager) (*httputil.Re
|
||||
req.Header.Del("Accept-Encoding")
|
||||
log.Debugf("[%s] Proxy request for %s", alertmanager.Name, req.URL.Path)
|
||||
},
|
||||
Transport: alertmanager.HTTPTransport,
|
||||
ModifyResponse: func(resp *http.Response) error {
|
||||
// drop Content-Length header from upstream responses, gzip middleware
|
||||
// will compress those and that could cause a mismatch
|
||||
|
||||
Reference in New Issue
Block a user