Scroll to navigation

Net::Prometheus::Histogram(3pm) User Contributed Perl Documentation Net::Prometheus::Histogram(3pm)

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.

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>
2018-10-18 perl v5.26.2