class NewRelic::Agent::EventBuffer
Attributes
capacity[R]
Public Class Methods
new(capacity)
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 22 def initialize(capacity) @capacity = capacity @items = [] @seen = 0 end
Public Instance Methods
<<(x)
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 47 def <<(x) append(x) self # return self for method chaining end
append(x)
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 42 def append(x) @seen += 1 append_event(x) end
capacity=(new_capacity)
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 33 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/new_relic/agent/event_buffer.rb, line 52 def full? @items.size >= @capacity end
metadata()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 80 def metadata { :capacity => @capacity, :captured => @items.size, :seen => @seen } end
note_dropped()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 60 def note_dropped @seen += 1 end
num_dropped()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 68 def num_dropped @seen - @items.size end
num_seen()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 64 def num_seen @seen end
reset!()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 28 def reset! @items = [] @seen = 0 end
sample_rate()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 72 def sample_rate @seen > 0 ? (size.to_f / @seen) : 0.0 end
size()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 56 def size @items.size end
to_a()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 76 def to_a @items.dup end