class OneApm::Agent::EventBuffer

Attributes

capacity[R]

Public Class Methods

new(capacity) click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 21
def initialize(capacity)
  @capacity = capacity
  @items    = []
  @seen     = 0
end

Public Instance Methods

<<(x) click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 46
def <<(x)
  append(x)
  self # return self for method chaining
end
append(x) click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 41
def append(x)
  @seen += 1
  append_event(x)
end
capacity=(new_capacity) click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 32
def capacity=(new_capacity)
  @capacity = new_capacity
  old_items = @items
  @items    = []
  old_seen  = @seen
  old_items.each { |i| append(i) }
  @seen     = old_seen
end
full?() click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 51
def full?
  @items.size >= @capacity
end
note_dropped() click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 59
def note_dropped
  @seen += 1
end
num_dropped() click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 67
def num_dropped
  @seen - @items.size
end
num_seen() click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 63
def num_seen
  @seen
end
reset!() click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 27
def reset!
  @items = []
  @seen  = 0
end
sample_rate() click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 71
def sample_rate
  @seen > 0 ? (size.to_f / @seen) : 0.0
end
size() click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 55
def size
  @items.size
end
to_a() click to toggle source
# File lib/one_apm/support/event_buffer.rb, line 75
def to_a
  @items.dup
end