Files
traces/tempodb/encoding/common/slackTimeRange.go
JaviandGitHub 64b0c0f885 rhythm: set ingestion slack for partition consumption (#4611)
* rhythm: set ingestion slack for partition consumption

* remove test

* Update WalBlock interface to explicitly compute the ingestionSlack

* add cycle duration to slack ingestion range calculation

* distinguish between ingesters and blockbuilder for dataquality warnings
2025-01-29 15:18:49 +01:00

30 lines
583 B
Go

package common
import (
"time"
"github.com/grafana/tempo/pkg/dataquality"
)
func AdjustTimeRangeForSlack(tenantID string, ingestionSlack time.Duration, start, end uint32) (uint32, uint32) {
now := time.Now()
startOfRange := uint32(now.Add(-ingestionSlack).Unix())
endOfRange := uint32(now.Add(ingestionSlack).Unix())
warn := false
if start < startOfRange {
warn = true
start = uint32(now.Unix())
}
if end > endOfRange || end < start {
warn = true
end = uint32(now.Unix())
}
if warn {
dataquality.WarnOutsideIngestionSlack(tenantID)
}
return start, end
}