class Crometheus::Gauge
- Crometheus::Gauge
- Crometheus::Metric
- Reference
- Object
Overview
Gauge is a Metric
type that stores a single value internally.
This value can be modified freely via instance methods.
require "crometheus/gauge"
body_temperature = Crometheus::Gauge.new(
:body_temperature, "Human body temperature")
body_temperature.set 98.6
# Running a fever...
body_temperature.inc 1.8
# Partial recovery
body_temperature.dec 0.6
body_temperature.get # => 99.8
Defined in:
crometheus/gauge.crClass Method Summary
-
.type
Returns
Type::Gauge
.
Instance Method Summary
-
#count_concurrent(&)
Increments the gauge value, yields, then decrements the gauge value.
-
#dec(x : Int | Float = 1.0)
Decrements the gauge value by the given number, or 1.0.
-
#get : Float64
Fetches the gauge value.
-
#inc(x : Int | Float = 1.0)
Increments the gauge value by the given number, or 1.0.
-
#measure_runtime(&)
Yields, then sets the gauge value to the block's runtime.
-
#samples(&block : Sample -> Nil) : Nil
Yields a single Sample bearing the gauge value.
-
#set(x : Int | Float)
Sets the gauge value to the given number.
-
#set_to_current_time
Sets the gauge value to the current UNIX timestamp.
Instance methods inherited from class Crometheus::Metric
docstring : String
docstring,
name : Symbol
name,
samples(&block : Sample -> Nil)
samples
Constructor methods inherited from class Crometheus::Metric
new(name : Symbol, docstring : String, register_with : Crometheus::Registry | Nil = Crometheus.default_registry)
new
Class methods inherited from class Crometheus::Metric
type
type,
valid_label?(label : Symbol) : Bool
valid_label?
Class Method Detail
Instance Method Detail
Increments the gauge value, yields, then decrements the gauge value. Wrap your event handlers with this to find out how many events are being processed at a time.
Yields a single Sample bearing the gauge value.
See Metric#samples
.