class

Crometheus::Gauge

Inherits Crometheus::Metric / Reference / Object

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

Class methods

type

Returns Type::Gauge. See Metric.type.

Source

Instance methods

count_concurrent

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.

Source
dec(x : Int | Float = 1.0)

Decrements the gauge value by the given number, or 1.0.

Source
get

Fetches the gauge value.

Source
inc(x : Int | Float = 1.0)

Increments the gauge value by the given number, or 1.0.

Source
measure_runtime

Yields, then sets the gauge value to the block's runtime.

Source
samples

Yields a single Sample bearing the gauge value. See Metric#samples.

Source
set(x : Int | Float)

Sets the gauge value to the given number.

Source
set_to_current_time

Sets the gauge value to the current UNIX timestamp.

Source