NAME

Net::Prometheus::Histogram - count the distribution of numeric observations

SYNOPSIS

use Net::Prometheus;
use Time::HiRes qw( time );

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

my $histogram = $client->new_histogram(
   name => "request_seconds",
   help => "Summary request processing time",
);

sub handle_request
{
   my $start = time();

   ...

   $summary->observe( time() - $start );
}

DESCRIPTION

This class provides a histogram metric - a count of the distribution of individual numerical observations into distinct buckets. These are usually reports of times. 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:

$histogram = $prometheus->new_histogram( %args );

This takes the same constructor arguments as documented in Net::Prometheus::Metric, and additionally the following:

buckets => ARRAY

A reference to an ARRAY containing numerical upper bounds for the buckets.

bucket_min => NUM
bucket_max => NUM
buckets_per_decade => ARRAY[ NUM ]

Since version 0.10.

A more flexible alternative to specifying literal bucket sizes. The values given in buckets_per_decade are repeated, multiplied by various powers of 10 to generate values between bucket_min (or a default of 0.001 if not supplied) and bucket_max (or a default of 1000 if not supplied).

bucket_bounds

@bounds = $histogram->bucket_bounds;

Returns the bounding values for each of the buckets, excluding the final +Inf bucket.

observe

$histogram->observe( @label_values, $value );
$histogram->observe( \%labels, $value );

$child->observe( $value );

Increment the histogram sum by the given value, and each bucket count by 1 where the value is less than or equal to the bucket upper bound.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>