mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix incorrect metric values for scheduler_behind_seconds (#45830)
This commit is contained in:
parent
304185f682
commit
6cccbb5a09
@ -368,7 +368,11 @@ func (sch *schedule) schedulePeriodic(ctx context.Context) error {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case tick := <-sch.ticker.C:
|
case tick := <-sch.ticker.C:
|
||||||
start := time.Now()
|
// We use Round(0) on the start time to remove the monotonic clock.
|
||||||
|
// This is required as late ticks from the ticker have current monotonic
|
||||||
|
// timestamps such that start.Sub(tick) does not return the expected
|
||||||
|
// delta.
|
||||||
|
start := time.Now().Round(0)
|
||||||
sch.metrics.BehindSeconds.Set(start.Sub(tick).Seconds())
|
sch.metrics.BehindSeconds.Set(start.Sub(tick).Seconds())
|
||||||
|
|
||||||
tickNum := tick.Unix() / int64(sch.baseInterval.Seconds())
|
tickNum := tick.Unix() / int64(sch.baseInterval.Seconds())
|
||||||
|
Loading…
Reference in New Issue
Block a user