{"id":16814990,"url":"https://github.com/markstory/rust-statsd","last_synced_at":"2025-05-16T14:06:58.752Z","repository":{"id":34684821,"uuid":"38658897","full_name":"markstory/rust-statsd","owner":"markstory","description":"Statsd client implemented in Rust","archived":false,"fork":false,"pushed_at":"2024-10-30T04:00:59.000Z","size":78,"stargazers_count":61,"open_issues_count":1,"forks_count":26,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T11:55:34.702Z","etag":null,"topics":["metrics","rust","statsd","statsd-client"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markstory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2015-07-07T02:28:51.000Z","updated_at":"2024-12-01T11:50:35.000Z","dependencies_parsed_at":"2024-11-16T20:02:28.972Z","dependency_job_id":null,"html_url":"https://github.com/markstory/rust-statsd","commit_stats":{"total_commits":87,"total_committers":16,"mean_commits":5.4375,"dds":"0.31034482758620685","last_synced_commit":"4145487debbf9c0133019b9175985ceadb08eaab"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markstory%2Frust-statsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markstory%2Frust-statsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markstory%2Frust-statsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markstory%2Frust-statsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markstory","download_url":"https://codeload.github.com/markstory/rust-statsd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442652,"owners_count":22071871,"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":["metrics","rust","statsd","statsd-client"],"created_at":"2024-10-13T10:32:05.293Z","updated_at":"2025-05-16T14:06:58.728Z","avatar_url":"https://github.com/markstory.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust Statsd\n\n[![CI status](https://github.com/markstory/rust-statsd/actions/workflows/ci.yml/badge.svg)](https://github.com/markstory/rust-statsd/actions/workflows/ci.yml)\n\nA StatsD client implementation of statsd in rust.\n\n## Using the client library\n\nAdd the `statsd` package as a dependency in your `Cargo.toml` file:\n\n```toml\n[dependencies]\nstatsd = \"^0.16\"\n```\n\nYou need rustc \u003e= 1.31.0 for statsd to work.\n\nYou can then get a client instance and start tracking metrics:\n\n```rust\n// Load the crate\nextern crate statsd;\n\n// Import the client object.\nuse statsd::Client;\n\n// Get a client with the prefix of `myapp`. The host should be the\n// IP:port of your statsd daemon.\nlet client = Client::new(\"127.0.0.1:8125\", \"myapp\").unwrap();\n```\n\n## Tracking Metrics\n\nOnce you've created a client, you can track timers and metrics:\n\n```rust\n// Increment a counter by 1\nclient.incr(\"some.counter\");\n\n// Decrement a counter by 1\nclient.decr(\"some.counter\");\n\n// Update a gauge\nclient.gauge(\"some.value\", 12.0);\n\n// Modify a counter by an arbitrary float.\nclient.count(\"some.counter\", 511.0);\n\n// Send a histogram value as a float.\nclient.histogram(\"some.histogram\", 511.0);\n\n// Send a key/value.\nclient.kv(\"some.data\", 15.26);\n```\n\n### Tracking Timers\n\nTimers can be updated using `timer()` and `time()`:\n\n```rust\n// Update a timer based on a calculation you've done.\nclient.timer(\"operation.duration\", 13.4);\n\n// Time a closure\nclient.time(\"operation.duration\", || {\n\t// Do something expensive.\n});\n```\n\n### Pipeline\n\nMultiple metrics can be sent to StatsD once using pipeline:\n\n```rust\nlet mut pipe = client.pipeline():\n\n// Increment a counter by 1\npipe.incr(\"some.counter\");\n\n// Decrement a counter by 1\npipe.decr(\"some.counter\");\n\n// Update a gauge\npipe.gauge(\"some.value\", 12.0);\n\n// Modify a counter by an arbitrary float.\npipe.count(\"some.counter\", 511.0);\n\n// Send a histogram value as a float.\npipe.histogram(\"some.histogram\", 511.0);\n\n// Send a key/value.\npipe.kv(\"some.data\", 15.26);\n\n// Set max UDP packet size if you wish, default is 512\npipe.set_max_udp_size(128);\n\n// Send to StatsD\npipe.send(\u0026client);\n```\n\nPipelines are also helpful to make functions simpler to test, as you can\npass a pipeline and be confident that no UDP packets will be sent.\n\n\n## License\n\nLicenesed under the [MIT License](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkstory%2Frust-statsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkstory%2Frust-statsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkstory%2Frust-statsd/lists"}