MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / gc

Method gc

pkg/rules/sequence.go:349–368  ·  view source on GitHub ↗

gc prunes the sequence partial if it remained more time than specified by max span or if max span is omitted, the partial is allowed to remain in sequence state for four hours.

()

Source from the content-addressed store, hash-verified

347// span is omitted, the partial is allowed to remain
348// in sequence state for four hours.
349func (s *sequenceState) gc() {
350 s.mu.Lock()
351 defer s.mu.Unlock()
352 dur := s.maxSpan
353 if dur == 0 {
354 dur = maxSequencePartialLifetime
355 }
356 for idx := range s.exprs {
357 for i := len(s.partials[idx]) - 1; i >= 0; i-- {
358 if len(s.partials[idx]) > 0 && time.Since(s.partials[idx][i].Timestamp) > dur {
359 log.Debugf("garbage collecting partial: [%s] of sequence [%s]", s.partials[idx][i], s.name)
360 // remove partial event from the corresponding slot
361 s.partials[idx] = append(
362 s.partials[idx][:i],
363 s.partials[idx][i+1:]...)
364 partialsPerSequence.Add(s.name, -1)
365 }
366 }
367 }
368}
369
370func (s *sequenceState) clear() {
371 s.partials = make(map[int][]*event.Event)

Callers 2

gcSequencesMethod · 0.80
TestSequenceGCFunction · 0.80

Calls 3

LockMethod · 0.80
UnlockMethod · 0.80
AddMethod · 0.65

Tested by 1

TestSequenceGCFunction · 0.64