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

Method CutIdle

pkg/livetraces/livetraces.go:121–145  ·  view source on GitHub ↗
(now time.Time, immediate bool)

Source from the content-addressed store, hash-verified

119}
120
121func (l *LiveTraces[T]) CutIdle(now time.Time, immediate bool) iter.Seq[*LiveTrace[T]] {
122 idleSince := now.Add(-l.maxIdleTime)
123 liveSince := now.Add(-l.maxLiveTime)
124
125 var toCut []*LiveTrace[T]
126 for k, tr := range l.Traces {
127 if tr.LastAppend.Before(idleSince) || tr.CreatedAt.Before(liveSince) || immediate {
128 l.sz -= tr.sz
129 delete(l.Traces, k)
130 toCut = append(toCut, tr)
131 }
132 }
133
134 sort.Slice(toCut, func(i, j int) bool {
135 return bytes.Compare(toCut[i].ID, toCut[j].ID) == -1
136 })
137
138 return func(yield func(*LiveTrace[T]) bool) {
139 for _, tr := range toCut {
140 if !yield(tr) {
141 return
142 }
143 }
144 }
145}

Callers 5

cutIdleTracesMethod · 0.80
TestCutIdleDueToIdleTimeFunction · 0.80
TestCutIdleDueToLiveTimeFunction · 0.80
BenchmarkLiveTracesReadFunction · 0.80

Calls 2

AddMethod · 0.65
CompareMethod · 0.45

Tested by 4

TestCutIdleDueToIdleTimeFunction · 0.64
TestCutIdleDueToLiveTimeFunction · 0.64
BenchmarkLiveTracesReadFunction · 0.64