The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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 lower bounds for the buckets.

observe

   $histogram->observe( [ @label_values ], $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 lower bound.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>