Class: Flipper::Cloud::Telemetry::MetricStorage
- Inherits:
-
Object
- Object
- Flipper::Cloud::Telemetry::MetricStorage
- Defined in:
- lib/flipper/cloud/telemetry/metric_storage.rb
Instance Method Summary collapse
- #drain ⇒ Object
- #empty? ⇒ Boolean
- #increment(metric) ⇒ Object
-
#initialize ⇒ MetricStorage
constructor
A new instance of MetricStorage.
Constructor Details
#initialize ⇒ MetricStorage
Returns a new instance of MetricStorage.
8 9 10 |
# File 'lib/flipper/cloud/telemetry/metric_storage.rb', line 8 def initialize @storage = Concurrent::Map.new { |h, k| h[k] = Concurrent::AtomicFixnum.new(0) } end |
Instance Method Details
#drain ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/flipper/cloud/telemetry/metric_storage.rb', line 16 def drain metrics = {} @storage.keys.each do |metric| metrics[metric] = @storage.delete(metric).value end metrics.freeze end |
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/flipper/cloud/telemetry/metric_storage.rb', line 24 def empty? @storage.empty? end |
#increment(metric) ⇒ Object
12 13 14 |
# File 'lib/flipper/cloud/telemetry/metric_storage.rb', line 12 def increment(metric) @storage[metric].increment end |