class Prometheus::Client::DataStores::Synchronized::MetricStore
Public Class Methods
new()
click to toggle source
# File lib/prometheus/client/data_stores/synchronized.rb, line 26 def initialize @internal_store = Hash.new { |hash, key| hash[key] = 0.0 } @lock = Monitor.new end
Public Instance Methods
all_values()
click to toggle source
# File lib/prometheus/client/data_stores/synchronized.rb, line 53 def all_values synchronize { @internal_store.dup } end
get(labels:)
click to toggle source
# File lib/prometheus/client/data_stores/synchronized.rb, line 47 def get(labels:) synchronize do @internal_store[labels] end end
increment(labels:, by: 1)
click to toggle source
# File lib/prometheus/client/data_stores/synchronized.rb, line 41 def increment(labels:, by: 1) synchronize do @internal_store[labels] += by end end
set(labels:, val:)
click to toggle source
# File lib/prometheus/client/data_stores/synchronized.rb, line 35 def set(labels:, val:) synchronize do @internal_store[labels] = val.to_f end end
synchronize() { || ... }
click to toggle source
# File lib/prometheus/client/data_stores/synchronized.rb, line 31 def synchronize @lock.synchronize { yield } end