4 releases (2 breaking)

Uses old Rust 2015

0.3.0 Feb 26, 2019
0.2.0 Feb 25, 2019
0.1.1 Dec 10, 2017
0.1.0 Dec 9, 2017

#1684 in Parser implementations

Download history 25/week @ 2024-07-27 93/week @ 2024-08-24 170/week @ 2024-08-31 160/week @ 2024-09-07 114/week @ 2024-09-14 1/week @ 2024-09-21 11/week @ 2024-09-28 21/week @ 2024-10-05 4/week @ 2024-10-12 1/week @ 2024-10-19 21/week @ 2024-10-26 33/week @ 2024-11-02

61 downloads per month

MIT/Apache

26KB
639 lines

(Dog)statsD Parser

Build Status

Parses (Dog)StatsD strings and returns a normalized struct.

All standard StatsD metric types are implemented. For DogStatsD sample rates and tags are implemented.

use statsd_parser;

#[test]
fn test_statsd_counter_with_sample_rate_and_tags() {
    let mut tags = BTreeMap::new();
    tags.insert("foo".to_string(), "bar".to_string());
    tags.insert("moo".to_string(), "maa".to_string());

    let expected = Metric::Counter(Counter {
        name: "gorets".to_string(),
        value: 1.0,
        sample_rate: Some(0.9),
        tags: Some(tags)
    });

    assert_eq!(parse("gorets:1|c|@0.9|#foo:bar,moo:maa"), Ok(expected));
}

License

Licensed under either of

at your option.

Contribution

Contributions are very welcome. Please make sure that you add a test for any use case you want to add.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps