Skip to content

Commit

Permalink
Merge pull request #13737 from bboreham/fix-scrape-tolerance
Browse files Browse the repository at this point in the history
[BUGFIX] Scraping: Tolerance should be max 1% of interval
  • Loading branch information
bboreham committed Mar 8, 2024
2 parents 9acae57 + 6c41ec9 commit 54f50e1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions scrape/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,10 +1218,8 @@ mainLoop:
// and .Add on time.Time behave differently (see time package docs).
scrapeTime := time.Now().Round(0)
if AlignScrapeTimestamps {
tolerance := ScrapeTimestampTolerance
if maxTolerance := sl.interval / 100; tolerance < maxTolerance {
tolerance = maxTolerance
}
// Tolerance is clamped to maximum 1% of the scrape interval.
tolerance := min(sl.interval/100, ScrapeTimestampTolerance)
// For some reason, a tick might have been skipped, in which case we
// would call alignedScrapeTime.Add(interval) multiple times.
for scrapeTime.Sub(alignedScrapeTime) >= sl.interval {
Expand Down

0 comments on commit 54f50e1

Please sign in to comment.