Skip to content
forked from erik/rust-statsd

Rust implementation of statsd server/client.

Notifications You must be signed in to change notification settings

Geal/rust-statsd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-statsd Build Status

It's a statsd server/client implementation. In Rust.

Run make to build the server/client. The server can be run with ./bin/statsd, the client library is available in ./lib/<arch>/libstatsd-...so.

Note: I wrote this in November 2013, and have been updating since to keep everything working on nightly builds of rust. As such, some of the code uses outdated idioms or workarounds for language shortcomings that no longer exist. In other words, the code is bound to be terrible.

Feedback is welcome.

Client

let statsd_host: SocketAddr = FromStr::from_str("hostname:8125").unwrap();
let client = statsd::Client::new(statsd_host);

// Increment the "foo" counter by 1 50% of the time.
client.incr("foo", 0.5);

// Decrement the "bar" counter by 1 10% of the time.
client.decr("bar", 0.1);

// Add 10 to the "foo" counter.
client.count("foo", 10);

// Subtract 10 from the "foo" counter 50% of the time.
client.count_sampled("foo", -10, 0.5);

// Set the "bar" gauge to 123.45
client.gauge("bar", 123.45);

// Add a run to the "quux" timer taking 300ms.
client.time("quux", 300);

// Add a run to "quux" with the time taken to execute the given proc.
client.time_block("quux", proc() { /* expensive computation here */ });

// Add a value to "foo" with the value 123.45
client.hist("foo", 123.45);

Server

Usage:

Usage: ./bin/statsd [options]
  -h --help               Show usage information
  --graphite host[:port]  Enable the graphite backend. Port will default to 2003 if not specified.
  --console               Enable console output.
  --port port             Have the statsd server listen on this UDP port. Defaults to 8125.
  --admin-port port       Have the admin server listen on this TCP port. Defaults to 8126.

Backends

Console

Prints out a YAML representation of the buckets on each flush.

2013-12-06T22:41:05-08:00:
  counters:
    a: 1
    b: 2
    c: 3
  gauges:
    d: 1
  timers:
    e:
      min: 0
      max: 8919
      count: 7137
      mean: 1087.236094
      stddev: 1824.204297
      upper_95: 5376.8

Graphite

Exports buckets in a Graphite-friendly format over a TCP stream.

License

MIT License

Copyright (c) 2013 Erik Price

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Rust implementation of statsd server/client.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%