mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-20 14:16:51 +08:00
26 lines
735 B
Go
26 lines
735 B
Go
package common
|
|
|
|
import (
|
|
"math"
|
|
"time"
|
|
|
|
v3 "go.signoz.io/signoz/pkg/query-service/model/v3"
|
|
)
|
|
|
|
func AdjustedMetricTimeRange(start, end, step int64, aggregaOperator v3.TimeAggregation) (int64, int64) {
|
|
start = start - (start % (step * 1000))
|
|
// if the query is a rate query, we adjust the start time by one more step
|
|
// so that we can calculate the rate for the first data point
|
|
if aggregaOperator.IsRateOperator() {
|
|
start -= step * 1000
|
|
}
|
|
adjustStep := int64(math.Min(float64(step), 60))
|
|
end = end - (end % (adjustStep * 1000))
|
|
return start, end
|
|
}
|
|
|
|
func PastDayRoundOff() int64 {
|
|
now := time.Now().UnixMilli()
|
|
return int64(math.Floor(float64(now)/float64(time.Hour.Milliseconds()*24))) * time.Hour.Milliseconds() * 24
|
|
}
|