Module: Promenade::Prometheus
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/promenade/prometheus.rb
Defined Under Namespace
Classes: Options
Constant Summary collapse
- REGISTRY_MUTEX =
Mutex.new
- METRICS_MUTEX =
Mutex.new
Class Method Summary collapse
Class Method Details
.define_metric(type, name, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/promenade/prometheus.rb', line 19 def self.define_metric(type, name, &block) METRICS_MUTEX.synchronize do return if registry.get(name) = Options.new .evaluate(&block) registry.method(type).call(name, *.args(type)) end end |
.metric(name) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/promenade/prometheus.rb', line 12 def self.metric(name) METRICS_MUTEX.synchronize do registry.get(name) || fail("No metric defined for: #{name}, you must define a metric before using it") end end |
.registry ⇒ Object
29 30 31 32 33 |
# File 'lib/promenade/prometheus.rb', line 29 def self.registry REGISTRY_MUTEX.synchronize do @_registry ||= ::Prometheus::Client.registry end end |