#datadog #client #apm


Datadog apm low level client for rust

4 releases

0.2.0 Jun 9, 2020
0.1.2 Feb 14, 2020
0.1.1 Feb 14, 2020
0.1.0 Feb 14, 2020

45 downloads per month

MIT license

355 lines

datadog apm

MIT licensed crates.io Released API docs

Unofficial Datadog APM for Rust.

Based on datadog documentation.


Check the docs for usage instructions.


Check the examples/ folder!


This project is licensed under the MIT license.


Unofficial Datadog APM for Rust.

Based on datadog documentation.


  • built for high throughput without block the caller (using tokio channel);
  • high configurable with sensible defaults;
  • efficient network and resource usage: traces buffering + serializing to messagepack;
  • discard traces when the buffer queue is full;
  • low-level, so it does not automatically instrument your code;


Add datadog_apm and tokio to your dependencies:

tokio = { version = "0.2", features = ["full"] }
datadog-apm = "0.2"
  • Create the client: (remember to reuse the same client instead of create a new one everytime, so the buffer can work)
use datadog_apm::{Client, Config};

let client = Client::new(Config {
    env: Some("production".to_string()),
    service: "my-crate".to_string(),
  • create a trace with spans: (for this example there is a span for a http request and a child-span for the sql transaction)
use datadog_apm::{Trace, Span, HttpInfo, ErrorInfo, SqlInfo};
use std::collections::HashMap;
use std::time::{Duration, SystemTime};

let trace = Trace {
    id: 123,
    priority: 1,
    spans: vec![Span {
         id: 1,
         parent_id: None,
         name: "request".to_string(),
         resource: "GET /path".to_string(),
         r#type: "web".to_string(),
         start: SystemTime::now(),
         duration: Duration::from_millis(50),
         http: Some(HttpInfo {
             url: String::from("/path/2?param=true"),
             method: String::from("GET"),
             status_code: String::from("500"),
         error: Some(ErrorInfo {
            r#type: "unknown".to_string(),
            msg: "Internal error".to_string(),
            stack: "stack here".to_string(),
         sql: None,
         tags: HashMap::new(),
    }, Span {
         id: 2,
         parent_id: Some(1),
         name: "database".to_string(),
         resource: "select".to_string(),
         r#type: "db".to_string(),
         start: SystemTime::now(),
         duration: Duration::from_millis(20),
         http: None,
         error: None,
         sql: Some(SqlInfo {
            query: "select 1".to_string(),
            rows: "1".to_string(),
            db: "test".to_string(),
         tags: HashMap::new(),
  • send the trace:

And that's it! The trace will be buffered and sent without block the current caller.


Check Config for all available configurations.

Features that are not included yet: (Contributions welcome!)


~148K SLoC