metrics-datadog-exporter

Crates.iometrics-datadog-exporter
lib.rsmetrics-datadog-exporter
version0.1.14
sourcesrc
created_at2021-05-19 17:01:55.289613
updated_at2023-11-20 21:05:13.61745
descriptionA `metrics` compatible exporter that sends metrics to DataDog
homepage
repositoryhttps://github.com/sevco/metrics-datadog-exporter-rs
max_upload_size
id399665
size102,150
Aaron Griffin (aig787)

documentation

https://docs.rs/metrics-datadog-exporter

README

metrics-datadog-exporter

Crates.io docs.rs GitHub Workflow Status

Metrics reporter for https://github.com/metrics-rs/metrics that writes to DataDog.

Usage

Writing to stdout

#[tokio::main]
async fn main() {
    let exporter = DataDogBuilder::default()
        .tags(vec![
            "tag1".to_string(),
            "val1".to_string()
        ])
        .build()
        .install()
        .unwrap();
    exporter.flush.await()?;
}

Writing to API

#[tokio::main]
async fn main() {
    let exporter = DataDogBuilder::default()
        .write_to_stdout(false)
        .write_to_api(true, Some("DD_API_KEY".to_string()))
        .tags(vec![
            "tag1".to_string(),
            "val1".to_string()
        ])
        .build()
        .install()
        .unwrap();
    exporter.flush.await()?;
}

Writing on a schedule

#[tokio::main]
async fn main() {
    let exporter = DataDogBuilder::default()
        .write_to_stdout(false)
        .write_to_api(true, Some("DD_API_KEY".to_string()))
        .tags(vec![
            "tag1".to_string(),
            "val1".to_string()
        ])
        .build()
        .install()
        .unwrap();
    let (_exporter, _scheduled) = exporter.schedule(Duration::from_secs(10));
}
Commit count: 65

cargo fmt