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: &'a Tags

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<StringEmitterError>

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();

Trait Implementations

impl<'a> Debug for Datum<'a>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<'a> Encodable for Datum<'a>
[src]

fn encode<__S: Encoder>(&self, __arg_0: &mut __S) -> Result<(), __S::Error>