Permalink
Browse files

First import of Net::Statsd source code

  • Loading branch information...
0 parents commit e399d8169a1721fdf783bb450866ea41d31087e8 @cosimo committed Nov 14, 2011
Showing with 417 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +130 −0 README.pod
  3. +40 −0 dist.ini
  4. +232 −0 lib/Net/Statsd.pm
  5. +7 −0 t/000-load.t
@@ -0,0 +1,8 @@
+.*.sw[po]
+pm_to_blib
+Makefile
+Makefile.old
+blib
+pod2htm*
+.build
+Net-Statsd-*
@@ -0,0 +1,130 @@
+=head1 NAME
+
+Net::Statsd - Perl client for Etsy's statsd daemon
+
+=head1 SYNOPSIS
+
+ # Configure where to send events
+ # That's where your statsd daemon is listening.
+ $Net::Statsd::HOST = 'localhost'; # Default
+ $Net::Statsd::PORT = 8125; # Default
+
+ #
+ # Keep track of events as counters
+ #
+ Net::Statsd::increment('site.logins');
+ Net::Statsd::increment('database.connects');
+
+ #
+ # Log timing of events, ex. db queries
+ #
+ use Time::HiRes;
+ my $start_time = [ Time::HiRes::gettimeofday ];
+
+ # do the complex database query
+ Net::Statsd::timing(
+ 'database.complexquery',
+ Time::HiRes::tv_interval($start_time)
+ );
+
+=head1 DESCRIPTION
+
+This module implement a UDP client for the B<statsd> statistics
+collector daemon in use at Etsy (http://www.etsy.com).
+
+You want to use this module to track statistics in your Perl
+application, such as how many times a certain event occurs
+(user logins in a web application, or database queries issued),
+or you want to time and then graph how long certain events take,
+like database queries execution time or time to download a
+certain file, etc...
+
+If you're uncertain whether you'd want to use this module or
+statsd, then you can read some background information here:
+
+ http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/
+
+The github repository for statsd is:
+
+ http://github.com/etsy/statsd
+
+By default the client will try to send statistic metrics to
+C<localhost:8125>, but you can change the default hostname and port
+with:
+
+ $Net::Statsd::HOST = 'your.statsd.hostname.net';
+ $Net::Statsd::PORT = 9999;
+
+just after including the C<Net::Statsd> module.
+
+=head1 FUNCTIONS
+
+
+=cut
+
+=head2 C<timing($stat, $time, $sample_rate = 1)>
+
+Log timing information.
+Time is assumed to be in milliseconds (ms).
+
+ Net::Statsd::timing('some.time', 500);
+
+
+=cut
+
+=head2 C<increment($stats, $sample_rate=1)>
+
+Increments one or more stats counters
+
+ # +1 on 'some.int'
+ Net::Statsd::increment('some.int');
+
+ # 0.5 = 50% sampling
+ Net::Statsd::increment('some.int', 0.5);
+
+To increment more than one counter at a time,
+you can B<pass an array reference>:
+
+ Net::Statsd::increment(['grue.dinners', 'room.lamps'], 1);
+
+B<You can also use "inc()" instead of "increment()" to type less>.
+
+
+=cut
+
+=head2 C<decrement($stats, $sample_rate=1)>
+
+Same as increment, but decrements. Yay.
+
+ Net::Statsd::decrement('some.int')
+
+B<You can also use "dec()" instead of "decrement()" to type less>.
+
+
+=cut
+
+=head2 C<update_stats($stats, $delta=1, $sample_rate=1)>
+
+Updates one or more stats counters by arbitrary amounts
+
+ Net::Statsd::update_stats('some.int', 10)
+
+equivalent to:
+
+ Net::Statsd::update_stats('some.int', 10, 1)
+
+A sampling rate less than 1 means only update the stats
+every x number of times (0.1 = 10% of the times).
+
+
+=cut
+
+=head2 C<send(\%data, $sample_rate=1)>
+
+Squirt the metrics over UDP.
+
+ Net::Statsd::send({ 'some.int' => 1 });
+
+
+=cut
+
@@ -0,0 +1,40 @@
+name = Net-Statsd
+author = Cosimo Streppone <cosimo@cpan.org>
+license = Perl_5
+copyright_holder = Cosimo Streppone
+copyright_year = 2011
+
+version = 0.01
+
+[@Basic]
+[PkgVersion]
+[InstallGuide]
+[MetaJSON]
+
+[MetaResources]
+bugtracker.web = http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Statsd
+bugtracker.mailto = bug-net-statsd@rt.cpan.org
+repository.url = git://github.com/cosimo/perl5-net-statsd.git
+repository.web = http://github.com/cosimo/perl5-net-statsd
+repository.type = git
+
+[PodWeaver]
+
+;[NoTabsTests]
+;[EOLTests]
+;[Signature]
+;[CheckChangeLog]
+
+[Prereqs]
+IO::Socket = 0
+
+[Prereqs / TestRequires]
+Test::More = 0
+
+[@Git]
+tag_format = CPAN-%v
+push_to = origin
+
+;[ConfirmRelease]
+;[UploadToCPAN]
+
Oops, something went wrong.

0 comments on commit e399d81

Please sign in to comment.