fix(inputs.prometheus): Remove duplicate response_timeout option (#15078)
This commit is contained in:
parent
572da25dce
commit
47e28d0f39
|
|
@ -141,6 +141,8 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|||
# timeout = "5s"
|
||||
|
||||
## deprecated in 1.26; use the timeout option
|
||||
## This option is now used by the HTTP client to set the header response
|
||||
## timeout, not the overall HTTP timeout.
|
||||
# response_timeout = "5s"
|
||||
|
||||
## HTTP Proxy support
|
||||
|
|
|
|||
|
|
@ -74,9 +74,8 @@ type Prometheus struct {
|
|||
|
||||
HTTPHeaders map[string]string `toml:"http_headers"`
|
||||
|
||||
ResponseTimeout config.Duration `toml:"response_timeout" deprecated:"1.26.0;use 'timeout' instead"`
|
||||
ContentLengthLimit config.Size `toml:"content_length_limit"`
|
||||
EnableRequestMetrics bool `toml:"enable_request_metrics"`
|
||||
ContentLengthLimit config.Size `toml:"content_length_limit"`
|
||||
EnableRequestMetrics bool `toml:"enable_request_metrics"`
|
||||
|
||||
MetricVersion int `toml:"metric_version"`
|
||||
|
||||
|
|
@ -213,15 +212,21 @@ func (p *Prometheus) Init() error {
|
|||
}
|
||||
|
||||
ctx := context.Background()
|
||||
if p.ResponseTimeout != 0 {
|
||||
p.HTTPClientConfig.Timeout = p.ResponseTimeout
|
||||
}
|
||||
|
||||
client, err := p.HTTPClientConfig.CreateClient(ctx, p.Log)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.client = client
|
||||
if p.HTTPClientConfig.ResponseHeaderTimeout != 0 {
|
||||
p.Log.Warn(
|
||||
"Config option response_timeout was set to non-zero value. This option's behavior was " +
|
||||
"changed in Telegraf 1.30.2 and now controls the HTTP client's header timeout and " +
|
||||
"not the Prometheus timeout. Users can ignore this warning if that was the intention. " +
|
||||
"Otherwise, please use the timeout config option for the Prometheus timeout.",
|
||||
)
|
||||
}
|
||||
|
||||
p.headers = map[string]string{
|
||||
"User-Agent": internal.ProductToken(),
|
||||
"Accept": acceptHeader,
|
||||
|
|
@ -406,9 +411,6 @@ func (p *Prometheus) gatherURL(u URLAndAddress, acc telegraf.Accumulator) (map[s
|
|||
},
|
||||
},
|
||||
}
|
||||
if p.ResponseTimeout != 0 {
|
||||
uClient.Timeout = time.Duration(p.ResponseTimeout)
|
||||
}
|
||||
} else {
|
||||
if u.URL.Path == "" {
|
||||
u.URL.Path = "/metrics"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/fields"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/config"
|
||||
"github.com/influxdata/telegraf/metric"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
)
|
||||
|
|
@ -241,10 +240,12 @@ func TestPrometheusGeneratesMetricsSlowEndpoint(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
p := &Prometheus{
|
||||
Log: testutil.Logger{},
|
||||
URLs: []string{ts.URL},
|
||||
URLTag: "url",
|
||||
ResponseTimeout: config.Duration(time.Second * 5),
|
||||
Log: testutil.Logger{},
|
||||
URLs: []string{ts.URL},
|
||||
URLTag: "url",
|
||||
client: &http.Client{
|
||||
Timeout: time.Second * 5,
|
||||
},
|
||||
}
|
||||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
|
@ -271,10 +272,12 @@ func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeout(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
p := &Prometheus{
|
||||
Log: testutil.Logger{},
|
||||
URLs: []string{ts.URL},
|
||||
URLTag: "url",
|
||||
ResponseTimeout: config.Duration(time.Second * 5),
|
||||
Log: testutil.Logger{},
|
||||
URLs: []string{ts.URL},
|
||||
URLTag: "url",
|
||||
client: &http.Client{
|
||||
Timeout: time.Second * 5,
|
||||
},
|
||||
}
|
||||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@
|
|||
# timeout = "5s"
|
||||
|
||||
## deprecated in 1.26; use the timeout option
|
||||
## This option is now used by the HTTP client to set the header response
|
||||
## timeout, not the overall HTTP timeout.
|
||||
# response_timeout = "5s"
|
||||
|
||||
## HTTP Proxy support
|
||||
|
|
|
|||
Loading…
Reference in New Issue