{"id":16315152,"url":"https://github.com/robrwo/net-statsd-lite","last_synced_at":"2025-10-25T17:30:26.345Z","repository":{"id":56835035,"uuid":"120469868","full_name":"robrwo/Net-Statsd-Lite","owner":"robrwo","description":"A lightweight statsd client that supports multimetric packets","archived":false,"fork":false,"pushed_at":"2024-12-29T17:36:43.000Z","size":134,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T09:22:33.129Z","etag":null,"topics":["perl","perl-module","statsd-client"],"latest_commit_sha":null,"homepage":"https://metacpan.org/release/Net-Statsd-Lite","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robrwo.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-06T14:28:15.000Z","updated_at":"2024-12-29T17:36:47.000Z","dependencies_parsed_at":"2024-07-13T13:39:30.272Z","dependency_job_id":null,"html_url":"https://github.com/robrwo/Net-Statsd-Lite","commit_stats":{"total_commits":164,"total_committers":3,"mean_commits":"54.666666666666664","dds":"0.012195121951219523","last_synced_commit":"a75967f93b486713e201951dcf4ef0558ceccac7"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FNet-Statsd-Lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FNet-Statsd-Lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FNet-Statsd-Lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FNet-Statsd-Lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robrwo","download_url":"https://codeload.github.com/robrwo/Net-Statsd-Lite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238183511,"owners_count":19430132,"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":["perl","perl-module","statsd-client"],"created_at":"2024-10-10T21:56:20.912Z","updated_at":"2025-10-25T17:30:21.029Z","avatar_url":"https://github.com/robrwo.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nNet::Statsd::Lite - A lightweight StatsD client that supports multimetric packets\n\n# VERSION\n\nversion v0.8.1\n\n# SYNOPSIS\n\n```perl\nuse Net::Statsd::Lite;\n\nmy $stats = Net::Statsd::Lite-\u003enew(\n  prefix          =\u003e 'myapp.',\n  autoflush       =\u003e 0,\n  max_buffer_size =\u003e 8192,\n);\n\n...\n\n$stats-\u003eincrement('this.counter');\n\n$stats-\u003eset_add( 'this.users', $username ) if $username;\n\n$stats-\u003etiming( $run_time * 1000 );\n\n$stats-\u003eflush;\n```\n\n# DESCRIPTION\n\nThis is a small StatsD client that supports the\n[StatsD Metrics Export Specification v0.1](https://github.com/b/statsd_spec).\n\nIt supports the following features:\n\n- Multiple metrics can be sent in a single UDP packet.\n- It supports the meter and histogram metric types.\n- It can extended to support extensions such as tagging.\n\nNote that the specification requires the measured values to be\nintegers no larger than 64-bits, but ideally 53-bits.\n\nThe current implementation expects values to be integers, except where\nspecified. But it otherwise does not enforce maximum/minimum values.\n\n# ATTRIBUTES\n\n## `host`\n\nThe host of the statsd daemon. It defaults to `127.0.0.1`.\n\n## `port`\n\nThe port that the statsd daemon is listening on. It defaults to\n`8125`.\n\n## `proto`\n\nThe network protocol that the statsd daemon is using. It defaults to\n`udp`.\n\n## `prefix`\n\nThe prefix to prepend to metric names. It defaults to a blank string.\n\n## `autoflush`\n\nA flag indicating whether metrics will be send immediately. It\ndefaults to true.\n\nWhen it is false, metrics will be saved in a buffer and only sent when\nthe buffer is full, or when the [\"flush\"](#flush) method is called.\n\nNote that when this is disabled, you will want to flush the buffer\nregularly at the end of each task (e.g. a website request or job).\n\nNot all StatsD daemons support receiving multiple metrics in a single\npacket.\n\n## `max_buffer_size`\n\nSpecifies the maximum buffer size. It defaults to `512`.\n\n# METHODS\n\n## `counter`\n\n```\n$stats-\u003ecounter( $metric, $value, $opts );\n```\n\nThis adds the `$value` to the counter specified by the `$metric`\nname.\n\n`$opts` can be a hash reference with the `rate` key, or a simple\nscalar with the `$rate`.\n\nIf a `$rate` is specified and less than 1, then a sampling rate will\nbe added. `$rate` must be between 0 and 1.\n\n## `update`\n\nThis is an alias for [\"counter\"](#counter), for compatability with\n[Etsy::StatsD](https://metacpan.org/pod/Etsy%3A%3AStatsD) or [Net::Statsd::Client](https://metacpan.org/pod/Net%3A%3AStatsd%3A%3AClient).\n\n## `increment`\n\n```\n$stats-\u003eincrement( $metric, $opts );\n```\n\nThis is an alias for\n\n```\n$stats-\u003ecounter( $metric, 1, $opts );\n```\n\n## `decrement`\n\n```\n$stats-\u003edecrement( $metric, $opts );\n```\n\nThis is an alias for\n\n```\n$stats-\u003ecounter( $metric, -1, $opts );\n```\n\n## `meter`\n\n```\n$stats-\u003emeter( $metric, $value, $opts );\n```\n\nThis is a counter that only accepts positive (increasing) values. It\nis appropriate for counters that will never decrease (e.g. the number\nof requests processed.)  However, this metric type is not supported by\nmany StatsD daemons.\n\n## `gauge`\n\n```\n$stats-\u003egauge( $metric, $value, $opts );\n```\n\nA gauge can be thought of as a counter that is maintained by the\nclient instead of the daemon, where `$value` is a positive integer.\n\nHowever, this also supports gauge increment extensions. If the number\nis prefixed by a \"+\", then the gauge is incremented by that amount,\nand if the number is prefixed by a \"-\", then the gauge is decremented\nby that amount.\n\n## `timing`\n\n```\n$stats-\u003etiming( $metric, $value, $opts );\n```\n\nThis logs a \"timing\" in milliseconds, so that statistics about the\nmetric can be gathered. The `$value` must be positive number,\nalthough the specification recommends that integers be used.\n\nIn actually, any values can be logged, and this is often used as a\ngeneric histogram for non-timing values (especially since many StatsD\ndaemons do not support the [\"histogram\"](#histogram) metric type).\n\n`$opts` can be a hash reference with a `rate` key, or a simple\nscalar with the `$rate`.\n\nIf a `$rate` is specified and less than 1, then a sampling rate will\nbe added. `$rate` must be between 0 and 1.  Note that sampling\nrates for timings may not be supported by all statsd servers.\n\n## `timing_ms`\n\nThis is an alias for [\"timing\"](#timing), for compatability with\n[Net::Statsd::Client](https://metacpan.org/pod/Net%3A%3AStatsd%3A%3AClient).\n\n## `histogram`\n\n```\n$stats-\u003ehistogram( $metric, $value, $opts );\n```\n\nThis logs a value so that statistics about the metric can be\ngathered. The `$value` must be a positive number, although the\nspecification recommends that integers be used.\n\nThis metric type is not supported by many StatsD daemons. You can use\n[\"timing\"](#timing) for the same effect.\n\n## `set_add`\n\n```\n$stats-\u003eset_add( $metric, $string, $opts );\n```\n\nThis adds the the `$string` to a set, for logging the number of\nunique things, e.g. IP addresses or usernames.\n\n## record\\_metric\n\nThis is an internal method for sending the data to the server.\n\n```\n$stats-\u003erecord_metric( $suffix, $metric, $value, $opts );\n```\n\nThis was renamed and documented in v0.5.0 to simplify subclassing\nthat supports extensions to statsd, such as tagging.\n\nSee the discussion of tagging extensions below.\n\n## `flush`\n\nThis sends the buffer to the [\"host\"](#host) and empties the buffer, if there\nis any data in the buffer.\n\n# STRICT MODE\n\nIf this module is first loaded in `STRICT` mode, then the values and\nrate arguments will be checked that they are the correct type.\n\nSee [Devel::StrictMode](https://metacpan.org/pod/Devel%3A%3AStrictMode) for more information.\n\n# TAGGING EXTENSIONS\n\nThis class does not support tagging out-of-the box. But tagging can be\nadded easily to a subclass, for example, [DogStatsd](https://www.datadoghq.com/) or\n[CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-custom-metrics-statsd.html)\ntagging can be added using something like\n\n```perl\nuse Moo 1.000000;\nextends 'Net::Statsd::Lite';\n\naround record_metric =\u003e sub {\n    my ( $next, $self, $suffix, $metric, $value, $opts ) = @_;\n\n    if ( my $tags = $opts-\u003e{tags} ) {\n        $suffix .= \"|#\" . join \",\", map { s/|//g; $_ } @$tags;\n    }\n\n    $self-\u003e$next( $suffix, $metric, $value, $opts );\n};\n```\n\n# SUPPORT FOR OLDER PERL VERSIONS\n\nSince v0.8.0, the this module requires Perl v5.20 or later.\n\nFuture releases may only support Perl versions released in the last ten years.\n\n# SEE ALSO\n\nThis module was forked from [Net::Statsd::Tiny](https://metacpan.org/pod/Net%3A%3AStatsd%3A%3ATiny).\n\n[https://github.com/statsd/statsd/blob/master/docs/metric\\_types.md](https://github.com/statsd/statsd/blob/master/docs/metric_types.md)\n\n[https://github.com/b/statsd\\_spec](https://github.com/b/statsd_spec)\n\n# SOURCE\n\nThe development version is on github at [https://github.com/robrwo/Net-Statsd-Lite](https://github.com/robrwo/Net-Statsd-Lite)\nand may be cloned from [git://github.com/robrwo/Net-Statsd-Lite.git](git://github.com/robrwo/Net-Statsd-Lite.git)\n\n# BUGS\n\nPlease report any bugs or feature requests on the bugtracker website\n[https://github.com/robrwo/Net-Statsd-Lite/issues](https://github.com/robrwo/Net-Statsd-Lite/issues)\n\nWhen submitting a bug or request, please include a test-file or a\npatch to an existing test-file that illustrates the bug or desired\nfeature.\n\n## Reporting Security Vulnerabilities\n\nSecurity issues should not be reported on the bugtracker website. Please see `SECURITY.md` for instructions how to\nreport security vulnerabilities\n\n# AUTHOR\n\nRobert Rothenberg \u003crrwo@cpan.org\u003e\n\nThe initial development of this module was sponsored by Science Photo\nLibrary [https://www.sciencephoto.com](https://www.sciencephoto.com).\n\n# CONTRIBUTORS\n\n- Michael R. Davis \u003cmrdvt@cpan.org\u003e\n- Toby Inkster \u003ctobyink@cpan.org\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is Copyright (c) 2018-2024 by Robert Rothenberg.\n\nThis is free software, licensed under:\n\n```\nThe Artistic License 2.0 (GPL Compatible)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Fnet-statsd-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobrwo%2Fnet-statsd-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Fnet-statsd-lite/lists"}