MCPcopy
hub / github.com/grafana/tempo / adjustTimeRangeForSlack

Method adjustTimeRangeForSlack

modules/blockbuilder/tenant_store.go:217–248  ·  view source on GitHub ↗

Adjust the time range based on when the record was added to the partition, factoring in slack and cycle duration. Any span with a start or end time outside this range will be constrained to the valid limits.

(start, end time.Time)

Source from the content-addressed store, hash-verified

215// Adjust the time range based on when the record was added to the partition, factoring in slack and cycle duration.
216// Any span with a start or end time outside this range will be constrained to the valid limits.
217func (s *tenantStore) adjustTimeRangeForSlack(start, end time.Time) (time.Time, time.Time) {
218 startOfRange := s.startTime.Add(-s.slackDuration)
219 endOfRange := s.startTime.Add(s.slackDuration + s.cycleDuration)
220
221 warn := false
222 if start.Before(startOfRange) {
223 warn = true
224 start = startOfRange
225 }
226 // clock skew, missconfiguration or simply data tampering
227 if start.After(endOfRange) {
228 warn = true
229 start = endOfRange
230 }
231 // this can happen with old spans added to Tempo
232 // setting it to start to not jump forward unexpectedly
233 if end.Before(start) {
234 warn = true
235 end = start
236 }
237
238 if end.After(endOfRange) {
239 warn = true
240 end = endOfRange
241 }
242
243 if warn {
244 dataquality.WarnBlockBuilderOutsideIngestionSlack(s.tenantID)
245 }
246
247 return start, end
248}
249
250func (s *tenantStore) determineBlockIDs(ctx context.Context, r tempodb.Reader) (nextID backend.UUID, existingBlocksToBeCompacted []backend.UUID, err error) {
251 for {

Callers 2

FlushMethod · 0.95

Calls 2

AddMethod · 0.65

Tested by 1