mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-24 10:56:53 +00:00
feat(telemetrymeter): step interval improvements
This commit is contained in:
parent
27305e6cc6
commit
712fa3e041
@ -173,7 +173,7 @@ func (q *querier) QueryRange(ctx context.Context, orgID valuer.UUID, req *qbtype
|
||||
event.GroupByApplied = len(spec.GroupBy) > 0
|
||||
|
||||
if spec.Signal == telemetrytypes.SignalMeter {
|
||||
spec.StepInterval = qbtypes.Step{Duration: time.Hour * 24}
|
||||
spec.StepInterval = qbtypes.Step{Duration: time.Second * time.Duration(querybuilder.RecommendedStepIntervalForMeter(req.Start, req.End))}
|
||||
} else {
|
||||
if spec.StepInterval.Seconds() == 0 {
|
||||
spec.StepInterval = qbtypes.Step{
|
||||
|
||||
@ -126,13 +126,11 @@ func newProvider(
|
||||
)
|
||||
|
||||
// Create meter statement builder
|
||||
meterFieldMapper := telemetrymetrics.NewFieldMapper()
|
||||
meterConditionBuilder := telemetrymetrics.NewConditionBuilder(metricFieldMapper)
|
||||
meterStmtBuilder := telemetrymeter.NewMeterQueryStatementBuilder(
|
||||
settings,
|
||||
telemetryMetadataStore,
|
||||
meterFieldMapper,
|
||||
meterConditionBuilder,
|
||||
metricFieldMapper,
|
||||
metricConditionBuilder,
|
||||
)
|
||||
|
||||
// Create bucket cache
|
||||
|
||||
@ -61,6 +61,23 @@ func MinAllowedStepInterval(start, end uint64) uint64 {
|
||||
return step - step%5
|
||||
}
|
||||
|
||||
func RecommendedStepIntervalForMeter(start, end uint64) uint64 {
|
||||
start = ToNanoSecs(start)
|
||||
end = ToNanoSecs(end)
|
||||
|
||||
step := (end - start) / RecommendedNumberOfPoints / 1e9
|
||||
|
||||
// for meter queries the minimum step interval allowed is 1 day as this is our granularity
|
||||
if step < 86400 {
|
||||
return 86400
|
||||
}
|
||||
|
||||
// return the nearest lower multiple of 86400 ( 1 day )
|
||||
recommended := step - step%86400
|
||||
|
||||
return recommended
|
||||
}
|
||||
|
||||
func RecommendedStepIntervalForMetric(start, end uint64) uint64 {
|
||||
start = ToNanoSecs(start)
|
||||
end = ToNanoSecs(end)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user