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

Method Allow

pkg/tracesizes/traceSizes.go:42–62  ·  view source on GitHub ↗

Allow returns true if the historical total plus incoming size is less than or equal to the max. The historical total is kept alive and incremented even if not allowed, so that long-running traces are cutoff as expected.

(traceID []byte, sz, maxSize int)

Source from the content-addressed store, hash-verified

40// or equal to the max. The historical total is kept alive and incremented even
41// if not allowed, so that long-running traces are cutoff as expected.
42func (s *Tracker) Allow(traceID []byte, sz, maxSize int) AllowResult {
43 s.mtx.Lock()
44 defer s.mtx.Unlock()
45
46 token := s.token(traceID)
47 tr := s.sizes[token]
48 if tr == nil {
49 tr = &traceSize{
50 size: 0, // size added below
51 }
52 s.sizes[token] = tr
53 }
54
55 tr.timestamp = time.Now()
56 tr.size += sz
57
58 return AllowResult{
59 tr.size <= maxSize,
60 tr.size,
61 }
62}
63
64func (s *Tracker) ClearIdle(idleSince time.Time) {
65 s.mtx.Lock()

Callers 1

pushBytesMethod · 0.80

Calls 2

tokenMethod · 0.95
NowMethod · 0.65

Tested by

no test coverage detected