mirror of https://github.com/status-im/consul.git
Fix: avoid redundant logs on failures to export metrics (#20519)
This commit is contained in:
parent
8ac54707d6
commit
c790740cc6
|
@ -28,7 +28,7 @@ const (
|
|||
)
|
||||
|
||||
// NewHTTPClient configures the retryable HTTP client.
|
||||
func NewHTTPClient(tlsCfg *tls.Config, source oauth2.TokenSource, logger hclog.Logger) *retryablehttp.Client {
|
||||
func NewHTTPClient(tlsCfg *tls.Config, source oauth2.TokenSource) *retryablehttp.Client {
|
||||
tlsTransport := cleanhttp.DefaultPooledTransport()
|
||||
tlsTransport.TLSClientConfig = tlsCfg
|
||||
|
||||
|
@ -43,8 +43,9 @@ func NewHTTPClient(tlsCfg *tls.Config, source oauth2.TokenSource, logger hclog.L
|
|||
}
|
||||
|
||||
retryClient := &retryablehttp.Client{
|
||||
HTTPClient: client,
|
||||
Logger: logger,
|
||||
HTTPClient: client,
|
||||
// We already log failed requests elsewhere, we pass a null logger here to avoid redundant logs.
|
||||
Logger: hclog.NewNullLogger(),
|
||||
RetryWaitMin: defaultRetryWaitMin,
|
||||
RetryWaitMax: defaultRetryWaitMax,
|
||||
RetryMax: defaultRetryMax,
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/hashicorp/consul/agent/hcp/config"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -18,7 +17,7 @@ func TestNewHTTPClient(t *testing.T) {
|
|||
mockHCPCfg, err := mockCfg.HCPConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
client := NewHTTPClient(mockHCPCfg.APITLSConfig(), mockHCPCfg, hclog.NewNullLogger())
|
||||
client := NewHTTPClient(mockHCPCfg.APITLSConfig(), mockHCPCfg)
|
||||
require.NotNil(t, client)
|
||||
|
||||
var req *http.Request
|
||||
|
|
|
@ -300,10 +300,7 @@ func (h *hcpProviderImpl) updateHTTPConfig(cfg config.CloudConfigurer) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to configure telemetry HTTP client: %v", err)
|
||||
}
|
||||
h.httpCfg.client = client.NewHTTPClient(
|
||||
hcpCfg.APITLSConfig(),
|
||||
hcpCfg,
|
||||
h.logger.Named("hcp_telemetry_client"))
|
||||
h.httpCfg.client = client.NewHTTPClient(hcpCfg.APITLSConfig(), hcpCfg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue