Class: Upfluence::Pool::PrometheusMetrics
- Inherits:
-
Object
- Object
- Upfluence::Pool::PrometheusMetrics
- Defined in:
- lib/upfluence/pool.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(registry, prefix, labels) ⇒ PrometheusMetrics
constructor
A new instance of PrometheusMetrics.
- #observe_discard ⇒ Object
- #observe_get ⇒ Object
- #observe_put ⇒ Object
- #observe_wait(seconds) ⇒ Object
- #set_size(count) ⇒ Object
- #update_checkout(count) ⇒ Object
- #update_idle(count) ⇒ Object
Constructor Details
#initialize(registry, prefix, labels) ⇒ PrometheusMetrics
Returns a new instance of PrometheusMetrics.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/upfluence/pool.rb', line 14 def initialize(registry, prefix, labels) label_keys = labels.keys @labels = labels @get = register(registry, :counter, :"#{prefix}_get_total", 'Total pool get calls', label_keys) @put = register(registry, :counter, :"#{prefix}_put_total", 'Total pool put calls', label_keys) @discard = register(registry, :counter, :"#{prefix}_discard_total", 'Total pool discard calls', label_keys) @get_wait = register(registry, :counter, :"#{prefix}_get_wait_total", 'Pool gets that had to wait', label_keys) @get_wait_duration = register(registry, :counter, :"#{prefix}_get_wait_millisecond_total", 'Total milliseconds waiting for pool get', label_keys) @idle = register(registry, :gauge, :"#{prefix}_idle", 'Idle resources in pool', label_keys) @checkout = register(registry, :gauge, :"#{prefix}_checkout", 'Checked out resources in pool', label_keys) @size = register(registry, :gauge, :"#{prefix}_size", 'Total pool size', label_keys) end |
Class Method Details
.standardized_metrics(n) ⇒ Object
9 10 11 12 |
# File 'lib/upfluence/pool.rb', line 9 def self.standardized_metrics(n) require 'prometheus/client' new(Prometheus::Client.registry, 'upfluence_iopool_pool', { pool: n }) end |
Instance Method Details
#observe_discard ⇒ Object
40 41 42 |
# File 'lib/upfluence/pool.rb', line 40 def observe_discard @discard.increment(labels: @labels) end |
#observe_get ⇒ Object
32 33 34 |
# File 'lib/upfluence/pool.rb', line 32 def observe_get @get.increment(labels: @labels) end |
#observe_put ⇒ Object
36 37 38 |
# File 'lib/upfluence/pool.rb', line 36 def observe_put @put.increment(labels: @labels) end |
#observe_wait(seconds) ⇒ Object
44 45 46 47 |
# File 'lib/upfluence/pool.rb', line 44 def observe_wait(seconds) @get_wait.increment(labels: @labels) @get_wait_duration.increment(by: (seconds * 1000).to_i, labels: @labels) end |
#set_size(count) ⇒ Object
57 58 59 |
# File 'lib/upfluence/pool.rb', line 57 def set_size(count) @size.set(count, labels: @labels) end |
#update_checkout(count) ⇒ Object
53 54 55 |
# File 'lib/upfluence/pool.rb', line 53 def update_checkout(count) @checkout.set(count, labels: @labels) end |
#update_idle(count) ⇒ Object
49 50 51 |
# File 'lib/upfluence/pool.rb', line 49 def update_idle(count) @idle.set(count, labels: @labels) end |