++ed by:
CKRAS ETHER

2 PAUSE user(s)
1 non-PAUSE user(s).

Andrew Rodland

NAME

Net::Statsd::Client::Timer - Measure event timings and send them to StatsD

VERSION

version 0.31

SYNOPSIS

    use Net::Statsd::Client;
    my $stats = Net::Statsd::Client->new(prefix => "service.frobnitzer.");

    my $timer = $stats->timer("request_duration");
    # ... do something expensive ...
    $timer->finish;

METHODS

Net::Statsd::Client::Timer->new(...)

To build a timer object, call Net::Statsd::Client's timer method, instead of calling this constructor directly.

A timer has an associated statsd object, metric name, and sample rate, and begins counting as soon as it's constructed.

$timer->finish

Stop timing, and send the elapsed time to the server.

$timer->cancel

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.

$timer->metric($new)

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;

AUTHOR

Andrew Rodland <arodland@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 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.




Hosting generously
sponsored by Bytemark