Datadog Formatting Layer
A crate providing a tracing-subscriber layer for formatting events so Datadog can parse them.
Features
- Provides a layer for tracing-subscriber
- Generates parsable "logs" for datadog and prints them to stdout
- Enables log correlation between spans and "logs" (see datadog docs)
Why not just tracing_subscriber::fmt().json()
?
The problem is, that datadog expects the "logs" to be in a specific (mostly undocumented) json format.
This crates tries to mimic this format.
Usage
Simple
use DatadogFormattingLayer;
use info;
use *;
registry
.with
.init;
info!;
Running this code will result in the following output on stdout:
With Opentelemetry
use DatadogFormattingLayer;
use ;
use ApiVersion;
use ;
use ;
// Just some otel boilerplate
set_text_map_propagator;
let tracer = new_pipeline
.with_service_name
.with_trace_config
.with_api_version
.with_env
.with_version
.install_simple
.unwrap;
// Use both the tracer and the formatting layer
registry
.with
.with
.init;
// Here no span exists
info!;
some_test;
// This will create a span and a trace id which is attached to the "logs"
When running this code with an datadog agent installed the logs will be sent to datadog and parsed there.
Otherwise the following output will be printed to stdout
Supported Opentelemetry versions:
Opentelemetry | DatadogFormattingLayer |
---|---|
0.20.* | 1.1.* |
0.19.* | 1.0.* |