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

Method flush

pkg/event/stackwalk.go:202–241  ·  view source on GitHub ↗

flush pushes events to the event queue if they have been living in the queue more than the maximum allowed TTL period.

()

Source from the content-addressed store, hash-verified

200// been living in the queue more than the maximum allowed
201// TTL period.
202func (s *StackwalkDecorator) flush() []error {
203 s.mux.Lock()
204 defer s.mux.Unlock()
205
206 if len(s.buckets) == 0 {
207 return nil
208 }
209
210 errs := make([]error, 0)
211
212 for id, q := range s.buckets {
213 n := make([]*Event, 0, len(q))
214 for _, evt := range q {
215 if time.Since(evt.Timestamp) < maxQueueTTLPeriod {
216 n = append(n, evt)
217 continue
218 }
219
220 stackwalkFlushes.Add(1)
221 err := s.q.push(evt)
222 if err != nil {
223 errs = append(errs, err)
224 }
225 if stackwalkEnqueued.Value() > 0 {
226 stackwalkEnqueued.Add(-1)
227 }
228 if evt.PS != nil {
229 stackwalkFlushesProcs.Add(evt.PS.Name, 1)
230 }
231 stackwalkFlushesEvents.Add(evt.Name, 1)
232 }
233 if len(n) == 0 {
234 delete(s.buckets, id)
235 } else {
236 s.buckets[id] = n
237 }
238 }
239
240 return errs
241}

Callers 1

doFlushMethod · 0.95

Calls 5

LockMethod · 0.80
UnlockMethod · 0.80
pushMethod · 0.80
AddMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected