Class: NewRelic::Agent::EventBuffer
- Inherits:
-
Object
- Object
- NewRelic::Agent::EventBuffer
- Defined in:
- lib/new_relic/agent/event_buffer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
Instance Method Summary collapse
- #<<(x) ⇒ Object
- #append(x) ⇒ Object
- #full? ⇒ Boolean
-
#initialize(capacity) ⇒ EventBuffer
constructor
A new instance of EventBuffer.
- #metadata ⇒ Object
- #note_dropped ⇒ Object
- #num_dropped ⇒ Object
- #num_seen ⇒ Object
- #reset! ⇒ Object
- #sample_rate ⇒ Object
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(capacity) ⇒ EventBuffer
Returns a new instance of EventBuffer.
23 24 25 26 27 |
# File 'lib/new_relic/agent/event_buffer.rb', line 23 def initialize(capacity) @capacity = capacity @items = [] @seen = 0 end |
Instance Attribute Details
#capacity ⇒ Object
21 22 23 |
# File 'lib/new_relic/agent/event_buffer.rb', line 21 def capacity @capacity end |
Instance Method Details
#<<(x) ⇒ Object
48 49 50 51 |
# File 'lib/new_relic/agent/event_buffer.rb', line 48 def <<(x) append(x) self # return self for method chaining end |
#append(x) ⇒ Object
43 44 45 46 |
# File 'lib/new_relic/agent/event_buffer.rb', line 43 def append(x) @seen += 1 append_event(x) end |
#full? ⇒ Boolean
53 54 55 |
# File 'lib/new_relic/agent/event_buffer.rb', line 53 def full? @items.size >= @capacity end |
#metadata ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/new_relic/agent/event_buffer.rb', line 81 def { :capacity => @capacity, :captured => @items.size, :seen => @seen } end |
#note_dropped ⇒ Object
61 62 63 |
# File 'lib/new_relic/agent/event_buffer.rb', line 61 def note_dropped @seen += 1 end |
#num_dropped ⇒ Object
69 70 71 |
# File 'lib/new_relic/agent/event_buffer.rb', line 69 def num_dropped @seen - @items.size end |
#num_seen ⇒ Object
65 66 67 |
# File 'lib/new_relic/agent/event_buffer.rb', line 65 def num_seen @seen end |
#reset! ⇒ Object
29 30 31 32 |
# File 'lib/new_relic/agent/event_buffer.rb', line 29 def reset! @items = [] @seen = 0 end |
#sample_rate ⇒ Object
73 74 75 |
# File 'lib/new_relic/agent/event_buffer.rb', line 73 def sample_rate @seen > 0 ? (size.to_f / @seen) : 0.0 end |
#size ⇒ Object
57 58 59 |
# File 'lib/new_relic/agent/event_buffer.rb', line 57 def size @items.size end |
#to_a ⇒ Object
77 78 79 |
# File 'lib/new_relic/agent/event_buffer.rb', line 77 def to_a @items.dup end |