mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Merge pull request #8601 from dgl/fix-8243
Ensure that timestamp comparison uses wall clock time
This commit is contained in:
commit
e14176756f
|
@ -1013,7 +1013,7 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) {
|
||||||
|
|
||||||
var last time.Time
|
var last time.Time
|
||||||
|
|
||||||
alignedScrapeTime := time.Now()
|
alignedScrapeTime := time.Now().Round(0)
|
||||||
ticker := time.NewTicker(interval)
|
ticker := time.NewTicker(interval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
@ -1031,7 +1031,9 @@ mainLoop:
|
||||||
// Temporary workaround for a jitter in go timers that causes disk space
|
// Temporary workaround for a jitter in go timers that causes disk space
|
||||||
// increase in TSDB.
|
// increase in TSDB.
|
||||||
// See https://github.com/prometheus/prometheus/issues/7846
|
// See https://github.com/prometheus/prometheus/issues/7846
|
||||||
scrapeTime := time.Now()
|
// Calling Round ensures the time used is the wall clock, as otherwise .Sub
|
||||||
|
// and .Add on time.Time behave differently (see time package docs).
|
||||||
|
scrapeTime := time.Now().Round(0)
|
||||||
if AlignScrapeTimestamps && interval > 100*scrapeTimestampTolerance {
|
if AlignScrapeTimestamps && interval > 100*scrapeTimestampTolerance {
|
||||||
// For some reason, a tick might have been skipped, in which case we
|
// For some reason, a tick might have been skipped, in which case we
|
||||||
// would call alignedScrapeTime.Add(interval) multiple times.
|
// would call alignedScrapeTime.Add(interval) multiple times.
|
||||||
|
|
Loading…
Reference in a new issue