3 unstable releases

0.2.1 Feb 21, 2021
0.2.0 Feb 21, 2021
0.1.0 Sep 4, 2020

#25 in #datadog

Download history 1231/week @ 2024-03-14 1317/week @ 2024-03-21 1213/week @ 2024-03-28 1039/week @ 2024-04-04 1098/week @ 2024-04-11 1197/week @ 2024-04-18 1609/week @ 2024-04-25 1218/week @ 2024-05-02 1086/week @ 2024-05-09 907/week @ 2024-05-16 1182/week @ 2024-05-23 1187/week @ 2024-05-30 1532/week @ 2024-06-06 989/week @ 2024-06-13 1206/week @ 2024-06-20 923/week @ 2024-06-27

4,909 downloads per month

MIT license

31KB
532 lines

Datadog Logs

What

datadog-logs is a minimalistic crate for logging to DataDog. It does it directly via HTTP(S) using DataDog's public API.

How

Logger consists of two parts - logging facade that sends messages to dedicated thread or task that batches messages to send to DataDog as presented on sequence diagram below.

sequence diagram of workflow

Thanks to such a workflow logging should not affect throughput of your application, nor force you to handle errors arising from HTTP.

Why

Author found no existing library that could be used for this purpose.

Feature flags

  • log-integration - enables integration with log crate (enabled by default)

lib.rs:

About

datadog-logs is a DataDog logs API client with log integration.

Provides support for HTTP DataDog logs ingestion API. Supports blocking and nonblocking HTTP(S) clients activated by feature flags.

Logger is easily configurable with extensive DataDogConfig that can be deserialized directly from file thanks to serde.

It offloads the job of sending logs to DataDog to a separate thread (blocking logger) or task (nonblocking logger).

Using with log crate

use datadog_logs::{config::DataDogConfig, logger::DataDogLogger, client::HttpDataDogClient};
use log::*;

let config = DataDogConfig::default();
let client = HttpDataDogClient::new(&config).unwrap();
 // there is also a blocking logger available that does not require runtime
let future = DataDogLogger::set_nonblocking_logger(client, config, LevelFilter::Error).unwrap();

 // there is a convinence function available to spawn future to tokio
 // however, this design makes it compatible with every runtime without effort
tokio::spawn(future);

 // now you can log
error!("An error occured");
warn!("A warning");

Dependencies

~3–18MB
~232K SLoC