Plack::Middleware::Prometheus::RequestTimes - record response times with a prometheus histogram.
version 0.0001
To setup a prometheus metrics app in your PSGI application register hook this middleware up with a histogram and the metrics can report on your response times.
use strict; use warnings; use My::Website; use Net::Prometheus; use Net::Prometheus::ProcessCollector; my $client = Net::Prometheus->new; $client->register( Net::Prometheus::ProcessCollector->new( prefix => "parent_process", pid => getppid(), ) ); my $response_times = $client->new_histogram( name => "response_times", help => "Application response times", ); use Plack::Builder; my $app = My::Website->apply_default_middlewares(My::Website->psgi_app); builder { mount "/metrics" => $client->psgi_app; mount '/' => builder { enable 'Prometheus::RequestTimes', observer => $response_times; $app; }; };
Normally a Net::Prometheus::Histogram object for recording the observations.
Colin Newell <colin@opusvl.com>
This software is copyright (c) 2016 by OpusVL.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Plack::Middleware::Prometheus::RequestTimes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::Prometheus::RequestTimes
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::Prometheus::RequestTimes
For more information on module installation, please visit the detailed CPAN module installation guide.