Struct bosun_emitter::Datum
[−]
[src]
pub struct Datum<'a> { pub metric: &'a str, pub timestamp: i64, pub value: &'a str, pub tags: &'a Tags, }
Represents a metric datum.
Fields
metric: &'a str
Metric name
timestamp: i64
Unix timestamp in either s or ms
value: &'a str
Value as string representation
Tags for this metric datum
Methods
impl<'a> Datum<'a>
[src]
fn new(metric: &'a str, timestamp: i64, value: &'a str, tags: &'a Tags) -> Datum<'a>
Creates a new metric datum with a specified timestamp in ms.
fn now(metric: &'a str, value: &'a str, tags: &'a Tags) -> Datum<'a>
Creates a new metric datum with timestamp now.
fn to_json(&self) -> Result<String, EmitterError>
Encodes a Datum to JSON as String.
Example
let mut tags = Tags::new(); tags.insert("host".to_string(), "test-vm".to_string()); let datum = Datum::new("lukas.tests.count", 1458066838, "1", &tags); let json = datum.to_json().unwrap();