fix: 延长数据统计时间
This commit is contained in:
parent
75cb5722f8
commit
7ca0198b33
@ -61,9 +61,9 @@ func (e *Exporter) Start(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now().In(e.loc)
|
now := time.Now().In(e.loc)
|
||||||
// 下一个10分钟边界 + 30s
|
// 下一个10分钟边界 + 1分钟(改为60秒延迟)
|
||||||
next := alignToNextBucketEnd(now, 10).Add(30 * time.Second)
|
next := alignToNextBucketEnd(now, 10).Add(1 * time.Minute)
|
||||||
e.logger.Printf("调度: 当前=%s, 下次执行=%s", now.Format("2006-01-02 15:04:05"), next.Format("2006-01-02 15:04:05"))
|
e.logger.Printf("调度: 当前=%s, 下次执行=%s (延迟1分钟)", now.Format("2006-01-02 15:04:05"), next.Format("2006-01-02 15:04:05"))
|
||||||
delay := time.Until(next)
|
delay := time.Until(next)
|
||||||
if delay > 0 {
|
if delay > 0 {
|
||||||
timer := time.NewTimer(delay)
|
timer := time.NewTimer(delay)
|
||||||
@ -75,11 +75,11 @@ func (e *Exporter) Start(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修正:当前时间是桶末,需要导出的是刚结束的上一个桶
|
// 当前时间是桶末,需要导出的是刚结束的上一个桶
|
||||||
// 例如:现在是20:50:30,应该导出的是20:40桶(表示20:40-20:50的数据)
|
// 例如:现在是21:01:00,应该导出的是20:50桶(表示20:50-21:00的数据)
|
||||||
currentTime := time.Now().In(e.loc)
|
currentTime := time.Now().In(e.loc)
|
||||||
bucketEnd := alignToPrevBucketEnd(currentTime, 10) // 上一个桶末,如20:50
|
bucketEnd := alignToPrevBucketEnd(currentTime, 10) // 上一个桶末,如21:00
|
||||||
bucketStart := bucketEnd.Add(-10 * time.Minute) // 上一个桶开始,如20:40
|
bucketStart := bucketEnd.Add(-10 * time.Minute) // 上一个桶开始,如20:50
|
||||||
|
|
||||||
e.logger.Printf("当前时间=%s, 导出桶=%s-%s",
|
e.logger.Printf("当前时间=%s, 导出桶=%s-%s",
|
||||||
currentTime.Format("2006-01-02 15:04:05"),
|
currentTime.Format("2006-01-02 15:04:05"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user