Permalink
Browse files

Clarified a few points in the documentation

  • Loading branch information...
1 parent 3ba14ff commit cd2056d4f3af94957a1f55be4217b27db9c36a9d @cosimo committed May 4, 2012
Showing with 23 additions and 22 deletions.
  1. +1 −1 dist.ini
  2. +19 −20 lib/Net/Statsd.pm
  3. +3 −1 t/000-load.t
View
@@ -4,7 +4,7 @@ license = Perl_5
copyright_holder = Cosimo Streppone
copyright_year = 2012
-version = 0.04
+version = 0.05
[@Basic]
[PkgVersion]
View
@@ -42,6 +42,11 @@ Net::Statsd - Perl client for Etsy's statsd daemon
Time::HiRes::tv_interval($start_time) * 1000
);
+ #
+ # Log metric values
+ #
+ Net::Statsd::gauge('core.temperature' => 55);
+
=head1 DESCRIPTION
This module implement a UDP client for the B<statsd> statistics
@@ -87,30 +92,32 @@ actually be sent to statsd).
=cut
-=head2 C<timing($stat, $time, $sample_rate = 1)>
+=head2 C<timing($name, $time, $sample_rate = 1)>
Log timing information.
B<Time is assumed to be in milliseconds (ms)>.
- Net::Statsd::timing('some.time', 500);
+ Net::Statsd::timing('some.timer', 500);
=cut
sub timing {
- my ($stat, $time, $sample_rate) = @_;
+ my ($name, $time, $sample_rate) = @_;
if (! defined $sample_rate) {
$sample_rate = 1;
}
my $stats = {
- $stat => sprintf "%d|ms", $time
+ $name => sprintf "%d|ms", $time
};
return Net::Statsd::send($stats, $sample_rate);
}
-=head2 C<increment($stats, $sample_rate=1)>
+=head2 C<increment($counter, $sample_rate=1)>
+
+=head2 C<increment(\@counter, $sample_rate=1)>
Increments one or more stats counters
@@ -138,7 +145,7 @@ sub increment {
*inc = *increment;
-=head2 C<decrement($stats, $sample_rate=1)>
+=head2 C<decrement($counter, $sample_rate=1)>
Same as increment, but decrements. Yay.
@@ -249,22 +256,22 @@ sub _sample_data {
return $sampled_data;
}
-=head2 C<gauge($stat, $gauge)>
+=head2 C<gauge($name, $value)>
-Log arbitrary values.
+Log arbitrary values, as a temperature, or server load.
- Net::Statsd::gauge('some.thing', 15);
+ Net::Statsd::gauge('core.temperature', 55);
=cut
sub gauge {
- my ($stat, $gauge) = @_;
+ my ($name, $value) = @_;
- $gauge = 0 unless defined $gauge;
+ $value = 0 unless defined $value;
# Didn't use '%d' because values might be floats
my $stats = {
- $stat => sprintf "%s|g", $gauge
+ $name => sprintf "%s|g", $value
};
return Net::Statsd::send($stats, 1);
@@ -320,12 +327,4 @@ sub send {
return $all_sent;
}
-unless (caller) {
- Net::Statsd::increment('test.counter1');
- Net::Statsd::increment('test.counter2');
- Net::Statsd::decrement('test.counter1');
- Net::Statsd::decrement('test.counter2');
-}
-
1;
-
View
@@ -1,7 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 1;
+use Test::More tests => 2;
use Net::Statsd;
ok(1, "Net::Statsd module loaded");
+my $version = Net::Statsd->VERSION();
+ok($version, "Net::Statsd version is $version");

0 comments on commit cd2056d

Please sign in to comment.