NAME
Graphite::Enumerator - Utility module to recursively enumerate graphite metrics
SYNOPSIS
my $gren = Graphite::Enumerator->new(
host => 'https://graphite.example.com',
basepath => 'general.metrics',
lwp_options => {
env_proxy => 1,
keep_alive => 1,
},
);
$gren->enumerate(sub {
my ($path) = @_;
print "Found metric $path !\n";
});
METHODS
Graphite::Enumerator->new(%args)
The constructor recognizes 3 arguments:
host => host name (in that case, the protocol defaults to http) or base URL
basepath => top-level metric namespace to scan
lwp_options => hash of options to initialize LWP::UserAgent internally
$g->enumerate($coderef)
Calls $coderef
for each metric under the basepath, with two parameters: 1. the metric name as a string; 2. the depth level of the metric relative to the base path (starting at 0).
$g->host
Returns the host passed to the constructor (with eventually http://
prepended).
$g->ua
Returns the internal LWP::UserAgent object.
$g->log_message($message)
Prints the $message
to STDOUT.
$g->log_warning($message)
Warns about the $message
.
ACKNOWLEDGMENT
This module was originally developed for Booking.com. With approval from Booking.com, this module was generalized and put on CPAN, for which the author would like to express his gratitude.
AUTHOR
Rafael Garcia-Suarez, <rgs@consttype.org>
This code is available under the same license as Perl version 5.10.1 or higher.
A git repository for this module is available at https://github.com/rgs/Graphite-Enumerator.