NAME

Net::Prometheus::Gauge - a snapshot value-reporting metric

SYNOPSIS

use Net::Prometheus;

my $client = Net::Prometheus->new;

my $gauge = $client->new_gauge(
   name => "users",
   help => "Number of current users",
);

my %users;
...

$gauge->set( scalar keys %users );

DESCRIPTION

This class provides a gauge metric - an arbitrary value that observes some snapshot of state at some instant in time. This is often used to report on the current usage of resources by the instrumented program, in a way that can decrease as well as increase. It is a subclass of Net::Prometheus::Metric.

CONSTRUCTOR

Instances of this class are not usually constructed directly, but instead via the Net::Prometheus object that will serve it:

$gauge = $prometheus->new_gauge( %args )

This takes the same constructor arguments as documented in Net::Prometheus::Metric.

METHODS

set

$gauge->set( [ @label_values ], $value )

$child->set( $value )

Sets the current value for the gauge.

If the gauge has any labels defined, the values for them must be given first.

inc

$gauge->inc( [ @label_values ], $delta )

$child->inc( $delta )

Increment the current value for the gauge. $delta will default to 1 if not supplied.

dec

$gauge->dec( [ @label_values ], $delta )

Decrement the current value for the gauge. $delta will default to 1 if not supplied.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>