mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
Merge pull request #8960 from prometheus/improve-scrape-timeout-header-formatting
Remove trailing zeros in scrape timeout header
This commit is contained in:
commit
6a055f118a
|
@ -24,6 +24,7 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
@ -718,7 +719,7 @@ func (s *targetScraper) scrape(ctx context.Context, w io.Writer) (string, error)
|
||||||
req.Header.Add("Accept", acceptHeader)
|
req.Header.Add("Accept", acceptHeader)
|
||||||
req.Header.Add("Accept-Encoding", "gzip")
|
req.Header.Add("Accept-Encoding", "gzip")
|
||||||
req.Header.Set("User-Agent", userAgentHeader)
|
req.Header.Set("User-Agent", userAgentHeader)
|
||||||
req.Header.Set("X-Prometheus-Scrape-Timeout-Seconds", fmt.Sprintf("%f", s.timeout.Seconds()))
|
req.Header.Set("X-Prometheus-Scrape-Timeout-Seconds", strconv.FormatFloat(s.timeout.Seconds(), 'f', -1, 64))
|
||||||
|
|
||||||
s.req = req
|
s.req = req
|
||||||
}
|
}
|
||||||
|
|
|
@ -1825,7 +1825,7 @@ func TestScrapeLoopOutOfBoundsTimeError(t *testing.T) {
|
||||||
func TestTargetScraperScrapeOK(t *testing.T) {
|
func TestTargetScraperScrapeOK(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
configTimeout = 1500 * time.Millisecond
|
configTimeout = 1500 * time.Millisecond
|
||||||
expectedTimeout = "1.500000"
|
expectedTimeout = "1.5"
|
||||||
)
|
)
|
||||||
|
|
||||||
server := httptest.NewServer(
|
server := httptest.NewServer(
|
||||||
|
|
Loading…
Reference in a new issue