fix: Rename the Prometheus Input Plugin Timeout variable (#12626)
This commit is contained in:
parent
fa26b6498b
commit
aa0b9d7dcf
|
|
@ -126,8 +126,11 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|||
# http_headers = {"X-Special-Header" = "Special-Value"}
|
||||
|
||||
## Specify timeout duration for slower prometheus clients (default is 3s)
|
||||
# timeout = "3s"
|
||||
|
||||
## deprecated in 1.26; use the timeout option
|
||||
# response_timeout = "3s"
|
||||
|
||||
|
||||
## HTTP Proxy support
|
||||
# use_system_proxy = false
|
||||
# http_proxy_url = ""
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ type Prometheus struct {
|
|||
|
||||
HTTPHeaders map[string]string `toml:"http_headers"`
|
||||
|
||||
ResponseTimeout config.Duration `toml:"response_timeout"`
|
||||
ResponseTimeout config.Duration `toml:"response_timeout" deprecated:"1.26.0;use 'timeout' instead"`
|
||||
Timeout config.Duration `toml:"timeout"`
|
||||
|
||||
MetricVersion int `toml:"metric_version"`
|
||||
|
||||
|
|
|
|||
|
|
@ -196,6 +196,59 @@ func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeout(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestPrometheusGeneratesMetricsSlowEndpointNewConfigParameter(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
time.Sleep(4 * time.Second)
|
||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
||||
require.NoError(t, err)
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
p := &Prometheus{
|
||||
Log: testutil.Logger{},
|
||||
URLs: []string{ts.URL},
|
||||
URLTag: "url",
|
||||
Timeout: config.Duration(time.Second * 5),
|
||||
}
|
||||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
var acc testutil.Accumulator
|
||||
|
||||
err = acc.GatherError(p.Gather)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.True(t, acc.HasFloatField("go_gc_duration_seconds", "count"))
|
||||
require.True(t, acc.HasFloatField("go_goroutines", "gauge"))
|
||||
require.True(t, acc.HasFloatField("test_metric", "value"))
|
||||
require.True(t, acc.HasTimestamp("test_metric", time.Unix(1490802350, 0)))
|
||||
require.False(t, acc.HasTag("test_metric", "address"))
|
||||
require.True(t, acc.TagValue("test_metric", "url") == ts.URL+"/metrics")
|
||||
}
|
||||
|
||||
func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeoutNewConfigParameter(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
time.Sleep(6 * time.Second)
|
||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
||||
require.NoError(t, err)
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
p := &Prometheus{
|
||||
Log: testutil.Logger{},
|
||||
URLs: []string{ts.URL},
|
||||
URLTag: "url",
|
||||
Timeout: config.Duration(time.Second * 5),
|
||||
}
|
||||
err := p.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
var acc testutil.Accumulator
|
||||
|
||||
err = acc.GatherError(p.Gather)
|
||||
require.ErrorContains(t, err, "error making HTTP request to "+ts.URL+"/metrics")
|
||||
}
|
||||
|
||||
func TestPrometheusGeneratesSummaryMetricsV2(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_, err := fmt.Fprintln(w, sampleSummaryTextFormat)
|
||||
|
|
|
|||
|
|
@ -109,8 +109,11 @@
|
|||
# http_headers = {"X-Special-Header" = "Special-Value"}
|
||||
|
||||
## Specify timeout duration for slower prometheus clients (default is 3s)
|
||||
# timeout = "3s"
|
||||
|
||||
## deprecated in 1.26; use the timeout option
|
||||
# response_timeout = "3s"
|
||||
|
||||
|
||||
## HTTP Proxy support
|
||||
# use_system_proxy = false
|
||||
# http_proxy_url = ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue