Skip to content

Commit

Permalink
Merge pull request #8960 from prometheus/improve-scrape-timeout-heade…
Browse files Browse the repository at this point in the history
…r-formatting

Remove trailing zeros in scrape timeout header
  • Loading branch information
RichiH committed Jun 18, 2021
2 parents 60918b8 + 9d495af commit 6a055f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion scrape/scrape.go
Expand Up @@ -24,6 +24,7 @@ import (
"math"
"net/http"
"reflect"
"strconv"
"sync"
"time"
"unsafe"
Expand Down Expand Up @@ -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-Encoding", "gzip")
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
}
Expand Down
2 changes: 1 addition & 1 deletion scrape/scrape_test.go
Expand Up @@ -1825,7 +1825,7 @@ func TestScrapeLoopOutOfBoundsTimeError(t *testing.T) {
func TestTargetScraperScrapeOK(t *testing.T) {
const (
configTimeout = 1500 * time.Millisecond
expectedTimeout = "1.500000"
expectedTimeout = "1.5"
)

server := httptest.NewServer(
Expand Down

0 comments on commit 6a055f1

Please sign in to comment.