GithubHelp home page GithubHelp logo

rust-statsd's Introduction

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.

rust-statsd's People

Contributors

erik avatar

Stargazers

@RandyMcMillan avatar Mike Filimonov avatar Geoffroy Couprie avatar Gabriel Wicke avatar ldng avatar Daniel Fagnan avatar

Watchers

 avatar James Cloos avatar Mike Filimonov avatar  avatar

Forkers

geal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.