| Crates.io | tracing-datadog |
| lib.rs | tracing-datadog |
| version | 0.6.1 |
| created_at | 2025-11-06 07:26:32.010145+00 |
| updated_at | 2026-01-05 01:24:35.213825+00 |
| description | tracing subscriber for DataDog |
| homepage | |
| repository | https://github.com/sulami/tracing-datadog |
| max_upload_size | |
| id | 1919222 |
| size | 91,096 |
A tracing exporter layer for Datadog, without dependencies on opentelemetry.
tracing traces to Datadog APMahash - Use AHashMaps instead of std HashMaps for performancehttp - HTTP Trace Context header support (W3C Trace Context and Datadog)To enable both trace data and log collection, use the DatadogTraceLayer layer
in your tracing subscriber:
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use tracing_datadog::DatadogTraceLayer;
tracing_subscriber::registry()
.with(
DatadogTraceLayer::builder()
.service("my-service")
.env("production")
.version("git sha")
.agent_address("localhost:8126")
.enable_logs(true)
.build()
.expect("failed to build DatadogTraceLayer"),
)
.init();
Logs will be emitted to stdout in the Datadog JSON format.
Certain span tags have special meaning in Datadog:
service - can be used to override the service on a per-span basisoperation - maps to Datadog APM operationsresource - maps to Datadog APM resourcesspan.kind - defaults to internal, but can be set to client, server,
producer, or consumer. Internal spans do not generate trace metrics.span.type - defaults to custom, but can be set to web for request
handlers, http for HTTP client requests, or any of sql, cassandra,
memcached, mongodb, elasticsearch, opensearch, redis, or db for
data store queries. custom can be used for any other type of span.There are few other semantic conventions, like the ones for errors. This page lists a lot of them.
To enable distributed tracing over HTTP, enable the http feature and use
DatadogContext to extract and inject trace context from/into HTTP headers.
See the API documentation for examples.
Some code has been adopted for the following projects:
See also komoju-datadog for opinionated usage of this library.