DOKK / manpages / debian 10 / libnet-prometheus-perl / Net::Prometheus::Histogram.3pm.en
Net::Prometheus::Histogram(3pm) User Contributed Perl Documentation Net::Prometheus::Histogram(3pm)

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

   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 );
   }

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.

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:

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

   $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.

Paul Evans <leonerd@leonerd.org.uk>

2018-10-18 perl v5.26.2