Method: OneApm::Agent::SampledBuffer#append_event

Defined in:
lib/one_apm/support/event_buffer/sampled_buffer.rb

#append_event(x) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/one_apm/support/event_buffer/sampled_buffer.rb', line 24

def append_event(x)
  if @items.size < @capacity
    @items << x
    return x
  else
    m = rand(@seen) # [0, @seen)
    if m < @capacity
      @items[m] = x
      return x
    else
      # discard current sample
      return nil
    end
  end
end