Class: FlowChat::Instrumentation::MetricsCollector
- Inherits:
-
Object
- Object
- FlowChat::Instrumentation::MetricsCollector
- Defined in:
- lib/flow_chat/instrumentation/metrics_collector.rb
Instance Attribute Summary collapse
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
Instance Method Summary collapse
-
#get_category(category) ⇒ Object
Get metrics for a specific category.
-
#initialize ⇒ MetricsCollector
constructor
A new instance of MetricsCollector.
-
#reset! ⇒ Object
Reset all metrics.
-
#snapshot ⇒ Object
Get current metrics snapshot.
Constructor Details
#initialize ⇒ MetricsCollector
Returns a new instance of MetricsCollector.
6 7 8 9 10 |
# File 'lib/flow_chat/instrumentation/metrics_collector.rb', line 6 def initialize @metrics = {} @mutex = Mutex.new subscribe_to_events end |
Instance Attribute Details
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
4 5 6 |
# File 'lib/flow_chat/instrumentation/metrics_collector.rb', line 4 def metrics @metrics end |
Instance Method Details
#get_category(category) ⇒ Object
Get metrics for a specific category
23 24 25 26 27 |
# File 'lib/flow_chat/instrumentation/metrics_collector.rb', line 23 def get_category(category) @mutex.synchronize do @metrics.select { |key, _| key.to_s.start_with?("#{category}.") } end end |
#reset! ⇒ Object
Reset all metrics
18 19 20 |
# File 'lib/flow_chat/instrumentation/metrics_collector.rb', line 18 def reset! @mutex.synchronize { @metrics.clear } end |
#snapshot ⇒ Object
Get current metrics snapshot
13 14 15 |
# File 'lib/flow_chat/instrumentation/metrics_collector.rb', line 13 def snapshot @mutex.synchronize { @metrics.dup } end |