Crates.io | statsd-parser |
lib.rs | statsd-parser |
version | 0.3.0 |
source | src |
created_at | 2017-12-09 23:22:13.587733 |
updated_at | 2019-02-26 14:21:32.285807 |
description | Library to parse (Dog)StatsD strings |
homepage | |
repository | https://github.com/appsignal/statsd_parser |
max_upload_size | |
id | 42288 |
size | 37,395 |
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));
}
Licensed under either of
at your option.
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.