{"id":18343411,"url":"https://github.com/cosimo/perl5-net-statsd","last_synced_at":"2025-06-21T05:07:25.023Z","repository":{"id":1846782,"uuid":"2771481","full_name":"cosimo/perl5-net-statsd","owner":"cosimo","description":"Net::Statsd is a Perl client for Etsy's statsd metric collection daemon","archived":false,"fork":false,"pushed_at":"2016-03-12T07:48:40.000Z","size":44,"stargazers_count":16,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T07:36:01.801Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"DrBoolean/patterns_talk","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cosimo.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-14T10:41:34.000Z","updated_at":"2022-04-30T03:19:55.000Z","dependencies_parsed_at":"2022-08-20T11:00:28.327Z","dependency_job_id":null,"html_url":"https://github.com/cosimo/perl5-net-statsd","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/cosimo/perl5-net-statsd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fperl5-net-statsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fperl5-net-statsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fperl5-net-statsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fperl5-net-statsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosimo","download_url":"https://codeload.github.com/cosimo/perl5-net-statsd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fperl5-net-statsd/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261066569,"owners_count":23104771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T20:35:57.272Z","updated_at":"2025-06-21T05:07:19.993Z","avatar_url":"https://github.com/cosimo.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"=pod\n\n=encoding utf-8\n\n=head1 NAME\n\nNet::Statsd - Perl client for Etsy's statsd daemon\n\n=head1 SYNOPSIS\n\n    # Configure where to send events\n    # That's where your statsd daemon is listening.\n    $Net::Statsd::HOST = 'localhost';    # Default\n    $Net::Statsd::PORT = 8125;           # Default\n\n    #\n    # Keep track of events as counters\n    #\n    Net::Statsd::increment('site.logins');\n    Net::Statsd::increment('database.connects');\n\n    #\n    # Log timing of events, ex. db queries\n    #\n    use Time::HiRes;\n    my $start_time = [ Time::HiRes::gettimeofday ];\n\n    # do the complex database query\n    # note: time value sent to timing should\n    # be in milliseconds.\n    Net::Statsd::timing(\n        'database.complexquery',\n        Time::HiRes::tv_interval($start_time) * 1000\n    );\n\n=head1 DESCRIPTION\n\nThis module implement a UDP client for the B\u003cstatsd\u003e statistics\ncollector daemon in use at Etsy.com.\n\nYou want to use this module to track statistics in your Perl\napplication, such as how many times a certain event occurs\n(user logins in a web application, or database queries issued),\nor you want to time and then graph how long certain events take,\nlike database queries execution time or time to download a\ncertain file, etc...\n\nIf you're uncertain whether you'd want to use this module or\nstatsd, then you can read some background information here:\n\n    http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/\n\nThe github repository for statsd is:\n\n    http://github.com/etsy/statsd\n\nBy default the client will try to send statistic metrics to\nC\u003clocalhost:8125\u003e, but you can change the default hostname and port\nwith:\n\n    $Net::Statsd::HOST = 'your.statsd.hostname.net';\n    $Net::Statsd::PORT = 9999;\n\njust after including the C\u003cNet::Statsd\u003e module.\n\n=head1 ABOUT SAMPLING\n\nA note about sample rate: A sample rate of \u003c 1 instructs this\nlibrary to send only the specified percentage of the samples to\nthe server. As such, the application code should call this module\nfor every occurence of each metric and allow this library to\ndetermine which specific measurements to deliver, based on the\nsample_rate value. (e.g. a sample rate of 0.5 would indicate that\napproximately only half of the metrics given to this module would\nactually be sent to statsd).\n\n=head1 FUNCTIONS\n\n\n=cut\n\n=head2 C\u003ctiming($stat, $time, $sample_rate = 1)\u003e\n\nLog timing information.\nB\u003cTime is assumed to be in milliseconds (ms)\u003e.\n\n    Net::Statsd::timing('some.time', 500);\n\n\n=cut\n\n=head2 C\u003cincrement($stats, $sample_rate=1)\u003e\n\nIncrements one or more stats counters\n\n    # +1 on 'some.int'\n    Net::Statsd::increment('some.int');\n\n    # 0.5 = 50% sampling\n    Net::Statsd::increment('some.int', 0.5);\n\nTo increment more than one counter at a time,\nyou can B\u003cpass an array reference\u003e:\n\n    Net::Statsd::increment(['grue.dinners', 'room.lamps'], 1);\n\nB\u003cYou can also use \"inc()\" instead of \"increment()\" to type less\u003e.\n\n\n\n=cut\n\n=head2 C\u003cdecrement($stats, $sample_rate=1)\u003e\n\nSame as increment, but decrements. Yay.\n\n    Net::Statsd::decrement('some.int')\n\nB\u003cYou can also use \"dec()\" instead of \"decrement()\" to type less\u003e.\n\n\n=cut\n\n=head2 C\u003cupdate_stats($stats, $delta=1, $sample_rate=1)\u003e\n\nUpdates one or more stats counters by arbitrary amounts\n\n    Net::Statsd::update_stats('some.int', 10)\n\nequivalent to:\n\n    Net::Statsd::update_stats('some.int', 10, 1)\n\nA sampling rate less than 1 means only update the stats\nevery x number of times (0.1 = 10% of the times).\n\n\n=cut\n\n=head2 C\u003c_sample_data(\\%data, $sample_rate = 1)\u003e\n\nB\u003cThis method is used internally, it's not part of the public interface.\u003e\n\nTakes care of transforming a hash of metrics data into\na B\u003csampled\u003e hash of metrics data, according to the given\nC\u003c$sample_rate\u003e.\n\nIf C\u003c$sample_rate == 1\u003e, then sampled data is exactly the\nincoming data.\n\nIf C\u003c$sample_rate = 0.2\u003e, then every metric value will be I\u003cmarked\u003e\nwith the given sample rate, so the Statsd server will automatically\nscale it. For example, with a sample rate of 0.2, the metric values\nwill be multiplied by 5.\n\n\n=cut\n\n=head2 C\u003cgauge($stat, $gauge)\u003e\n\nLog arbitrary values.\n\n    Net::Statsd::gauge('some.thing', 15);\n\n\n=cut\n\n=head2 C\u003csend(\\%data, $sample_rate = 1)\u003e\n\nSquirt the metrics over UDP.\n\n    Net::Statsd::send({ 'some.int' =\u003e 1 });\n\n\n=cut\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosimo%2Fperl5-net-statsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosimo%2Fperl5-net-statsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosimo%2Fperl5-net-statsd/lists"}