Net::Statsd::Client::Timer - Measure event timings and send them to StatsD
version 0.34
use Net::Statsd::Client; my $stats = Net::Statsd::Client->new(prefix => "service.frobnitzer."); my $timer = $stats->timer("request_duration"); # ... do something expensive ... $timer->finish;
To build a timer object, call Net::Statsd::Client's timer method, instead of calling this constructor directly.
timer
A timer has an associated statsd object, metric name, and sample rate, and begins counting as soon as it's constructed.
Stop timing, and send the elapsed time to the server. Returns the elapsed time in milliseconds.
Stop timing, but do not send the elapsed time to the server. A timer that goes out of scope without having finish or cancel called on it will generate a warning, since this probably points to bugs and lost timing information.
finish
cancel
Change the metric name of a timer on the fly. This is useful if you don't know what kind of event you're timing until it's finished. Harebrained example:
my $timer = $statsd->timer("item.fetch"); my $item = $cache->get("blah"); if ($item) { $timer->metric("item.fetch_from_cache"); } else { $item = get_it_the_long_way(); } $timer->finish;
Andrew Rodland <arodland@cpan.org>
This software is copyright (c) 2018 by Andrew Rodland.
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 Net::Statsd::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Statsd::Client
CPAN shell
perl -MCPAN -e shell install Net::Statsd::Client
For more information on module installation, please visit the detailed CPAN module installation guide.