Class: MetricSense::Context
- Inherits:
-
Object
- Object
- MetricSense::Context
- Defined in:
- lib/metricsense.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
- #clear! ⇒ Object
- #event(tag) ⇒ Object (also: #[])
-
#initialize(collector) ⇒ Context
constructor
A new instance of Context.
- #measure! ⇒ Object
Constructor Details
#initialize(collector) ⇒ Context
Returns a new instance of Context.
88 89 90 91 |
# File 'lib/metricsense.rb', line 88 def initialize(collector) @collector = collector @events = {} end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
93 94 95 |
# File 'lib/metricsense.rb', line 93 def events @events end |
Instance Method Details
#clear! ⇒ Object
101 102 103 104 |
# File 'lib/metricsense.rb', line 101 def clear! @events.clear nil end |
#event(tag) ⇒ Object Also known as: []
95 96 97 |
# File 'lib/metricsense.rb', line 95 def event(tag) @events[tag] ||= Event.new(tag) end |
#measure! ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'lib/metricsense.rb', line 106 def measure! return nil unless @collector @events.keys.each {|k| event = @events[k] @collector.measure(event) if event.tag @events.delete(k) } nil end |