NAME
Plack::Middleware::Prometheus::RequestTimes - record response times with a prometheus histogram.
VERSION
version 0.0001
DESCRIPTION
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;
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
;
};
};
CONFIGURATION
observer
Normally a Net::Prometheus::Histogram object for recording the observations.
AUTHOR
Colin Newell <colin@opusvl.com>
COPYRIGHT AND LICENSE
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.