Class: OneApm::Agent::EventBuffer
- Inherits:
-
Object
- Object
- OneApm::Agent::EventBuffer
show all
- Defined in:
- lib/one_apm/support/event_buffer.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(capacity) ⇒ EventBuffer
Returns a new instance of EventBuffer.
21
22
23
24
25
|
# File 'lib/one_apm/support/event_buffer.rb', line 21
def initialize(capacity)
@capacity = capacity
@items = []
@seen = 0
end
|
Instance Attribute Details
#capacity ⇒ Object
Returns the value of attribute capacity.
19
20
21
|
# File 'lib/one_apm/support/event_buffer.rb', line 19
def capacity
@capacity
end
|
Instance Method Details
#<<(x) ⇒ Object
46
47
48
49
|
# File 'lib/one_apm/support/event_buffer.rb', line 46
def <<(x)
append(x)
self end
|
#append(x) ⇒ Object
41
42
43
44
|
# File 'lib/one_apm/support/event_buffer.rb', line 41
def append(x)
@seen += 1
append_event(x)
end
|
#full? ⇒ Boolean
51
52
53
|
# File 'lib/one_apm/support/event_buffer.rb', line 51
def full?
@items.size >= @capacity
end
|
#note_dropped ⇒ Object
59
60
61
|
# File 'lib/one_apm/support/event_buffer.rb', line 59
def note_dropped
@seen += 1
end
|
#num_dropped ⇒ Object
67
68
69
|
# File 'lib/one_apm/support/event_buffer.rb', line 67
def num_dropped
@seen - @items.size
end
|
#num_seen ⇒ Object
63
64
65
|
# File 'lib/one_apm/support/event_buffer.rb', line 63
def num_seen
@seen
end
|
#reset! ⇒ Object
27
28
29
30
|
# File 'lib/one_apm/support/event_buffer.rb', line 27
def reset!
@items = []
@seen = 0
end
|
#sample_rate ⇒ Object
71
72
73
|
# File 'lib/one_apm/support/event_buffer.rb', line 71
def sample_rate
@seen > 0 ? (size.to_f / @seen) : 0.0
end
|
#size ⇒ Object
55
56
57
|
# File 'lib/one_apm/support/event_buffer.rb', line 55
def size
@items.size
end
|
#to_a ⇒ Object
75
76
77
|
# File 'lib/one_apm/support/event_buffer.rb', line 75
def to_a
@items.dup
end
|