Code Monkey home page Code Monkey logo

dogstatsd-rs's Introduction

dogstatsd-rs

Build Status Crate Version

A Rust client for interacting with Dogstatsd

Dogstatsd is a custom StatsD implementation by DataDog for sending metrics and events to their system. Through this client you can report any type of metric you want, tag it, and enjoy your custom metrics.

Full Documentation

Usage

Build an options struct and create a client:

use dogstatsd::{Client, Options};

// Binds to a udp socket on 127.0.0.1:8126 for transmitting, and sends to
// 127.0.0.1:8125, the default dogstatsd address.
let default_options = Options::default();
let default_client = Client::new(default_options);

// Binds to 127.0.0.1:9000 for transmitting and sends to 10.1.2.3:8125, with a
// namespace of "analytics".
let custom_options = Options::new("127.0.0.1:9000", "10.1.2.3:8125", "analytics");
let custom_client = Client::new(custom_options);

Start sending metrics:

use dogstatsd::{Client, Options};

let client = Client::new(Options::default());

// Increment a counter
client.incr("my_counter", &[]).unwrap();

// Decrement a counter
client.decr("my_counter", &[]).unwrap();

// Time a block of code (reports in ms)
client.time("my_time", &[], || {
    // Some time consuming code
}).unwrap();

// Report your own timing in ms
client.timing("my_timing", 500, &[]).unwrap();

// Report an arbitrary value (a gauge)
client.gauge("my_gauge", "12345", &[]).unwrap();

// Report a sample of a histogram
client.histogram("my_histogram", "67890", &[]).unwrap();

// Report a member of a set
client.set("my_set", "13579", &[]).unwrap();

// Send a custom event
client.event("My Custom Event Title", "My Custom Event Body", &[]).unwrap();

// Add tags to any metric by passing an array of tags to apply
client.gauge("my_gauge", "12345", &["tag:1", "tag:2"]).unwrap();

dogstatsd-rs's People

Contributors

mcasper avatar mhseiden avatar jlgale avatar mtoader avatar

Watchers

 avatar James Cloos avatar Donald Huang avatar

Forkers

mtoader jmhain

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.