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

Method waitForQueryEndCutoff

integration/util/harness.go:406–430  ·  view source on GitHub ↗

waitForQueryEndCutoff sleeps until enough wall-clock time has passed since the last recorded write for traces to fall inside the queryable window defined by query_frontend.query_end_cutoff. Skipped when no writes have been recorded or when the cutoff is disabled (<= 0).

(t *testing.T)

Source from the content-addressed store, hash-verified

404// query_frontend.query_end_cutoff. Skipped when no writes have been recorded or when
405// the cutoff is disabled (<= 0).
406func (h *TempoHarness) waitForQueryEndCutoff(t *testing.T) {
407 t.Helper()
408
409 lastWrite := h.lastWriteUnixNano.Load()
410 if lastWrite == 0 {
411 return
412 }
413
414 cfg, err := h.GetConfig()
415 require.NoError(t, err)
416
417 cutoff := cfg.Frontend.QueryEndCutoff
418 if cutoff <= 0 {
419 return
420 }
421
422 // Tiny buffer to absorb clock skew between this process and the live-store containers.
423 // The wait is already conservative: the trace's span timestamps were assigned before the
424 // write completed, so lastWrite is strictly newer than the trace timestamp.
425 const buffer = 100 * time.Millisecond
426 waitUntil := time.Unix(0, lastWrite).Add(cutoff).Add(buffer)
427 if remaining := time.Until(waitUntil); remaining > 0 {
428 time.Sleep(remaining)
429 }
430}
431
432func (h *TempoHarness) WaitTracesWrittenToBackend(t *testing.T, traces int) {
433 t.Helper()

Callers 1

WaitTracesQueryableMethod · 0.95

Calls 3

GetConfigMethod · 0.95
AddMethod · 0.65
SleepMethod · 0.65

Tested by

no test coverage detected