Skip to content

Commit

Permalink
Remove trailing zeros in scrape timeout header
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusv committed Jun 18, 2021
1 parent 9e88c3b commit 9d495af
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 9d495af

Please sign in to comment.