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 23 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 48 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 43 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 34 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 53 def full? @items.size >= @capacity end
metadata()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 81 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 61 def note_dropped @seen += 1 end
num_dropped()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 69 def num_dropped @seen - @items.size end
num_seen()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 65 def num_seen @seen end
reset!()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 29 def reset! @items = [] @seen = 0 end
sample_rate()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 73 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 57 def size @items.size end
to_a()
click to toggle source
# File lib/new_relic/agent/event_buffer.rb, line 77 def to_a @items.dup end