Class: Tracekit::Metrics::Gauge
- Inherits:
-
Object
- Object
- Tracekit::Metrics::Gauge
- Defined in:
- lib/tracekit/metrics/gauge.rb
Overview
Gauge metric - point-in-time value that can increase or decrease Used for tracking current values like active connections, memory usage, etc.
Instance Method Summary collapse
-
#dec ⇒ Object
Decrements the gauge by 1.
-
#inc ⇒ Object
Increments the gauge by 1.
-
#initialize(name, tags, registry) ⇒ Gauge
constructor
A new instance of Gauge.
-
#set(value) ⇒ Object
Sets the gauge to a specific value.
Constructor Details
#initialize(name, tags, registry) ⇒ Gauge
Returns a new instance of Gauge.
8 9 10 11 12 13 14 |
# File 'lib/tracekit/metrics/gauge.rb', line 8 def initialize(name, , registry) @name = name @tags = || {} @registry = registry @value = 0.0 @mutex = Mutex.new end |
Instance Method Details
#dec ⇒ Object
Decrements the gauge by 1
34 35 36 37 38 39 |
# File 'lib/tracekit/metrics/gauge.rb', line 34 def dec @mutex.synchronize do @value -= 1 @registry.record_metric(@name, "gauge", @value, @tags) end end |
#inc ⇒ Object
Increments the gauge by 1
26 27 28 29 30 31 |
# File 'lib/tracekit/metrics/gauge.rb', line 26 def inc @mutex.synchronize do @value += 1 @registry.record_metric(@name, "gauge", @value, @tags) end end |
#set(value) ⇒ Object
Sets the gauge to a specific value
18 19 20 21 22 23 |
# File 'lib/tracekit/metrics/gauge.rb', line 18 def set(value) @mutex.synchronize do @value = value @registry.record_metric(@name, "gauge", @value, @tags) end end |