@@ -12,7 +12,7 @@ They don't have similar support for Rust. However, they do support the
1212This crate contains the necessary glue to bridge the gap between OpenTelemetry
1313and Datadog.
1414
15- # Features
15+ # Further Information and Rationale
1616## Tracing
1717For traces, the official Datadog agent
1818[ can ingest OTel trace data] ( https://docs.datadoghq.com/opentelemetry/ )
@@ -21,7 +21,7 @@ via either HTTP or gRPC. More information on this can be found here:
2121https://docs.datadoghq.com/opentelemetry/otlp_ingest_in_the_agent/?tab=docker
2222
2323OpenTelemetry has an official Rust crate with extensions for major
24- formats/providers. This includes a datadog exporter. We have found
24+ formats/providers. This includes a Datadog exporter. We have found
2525this exporter to be less reliable than the standard OTel exporter
2626sending data to the OTel endpoint of the Datadog agent, though.
2727
@@ -39,14 +39,39 @@ transform the trace ID to the Datadog native format.
3939
4040## Propagation
4141The Python library takes care of propagation of the trace context automatically.
42- Unfortunately, we need to do this manually in Rust. There are many protocols and
43- corresponding libraries we could support, but the main one is HTTP requests.
42+ Unfortunately, we need to do this manually in Rust.
4443
4544In Rust, ` reqwest ` is the most commonly used HTTP client crate. We provide a
4645` reqwest ` middleware that injects the necessary headers using the Datadog native
4746propagation standard (common alternatives would be Jaeger and B3, more on this:
4847https://opentelemetry.io/docs/reference/specification/context/api-propagators/#propagators-distribution ).
4948
49+ This crate does not provide any additional support, but we recommend using
50+ the [ reqwest-middleware] ( https://crates.io/crates/reqwest-middleware ) crate
51+ to inject the necessary headers. If you set the global propagator using
52+ ` ddtrace ` , it will work out of the box.
53+
54+ ``` rust
55+ use ddtrace :: set_global_propagator;
56+ use reqwest_middleware :: {ClientBuilder , ClientWithMiddleware };
57+ use reqwest_tracing :: TracingMiddleware ;
58+
59+ #[tokio:: main]
60+ async fn main () {
61+ set_global_propagator ();
62+ client = get_http_client ();
63+
64+ // configure tracing, setup your app and inject the client
65+ }
66+
67+ fn get_http_client () -> ClientWithMiddleware {
68+ ClientBuilder :: new (reqwest :: Client :: new ())
69+ . with (TracingMiddleware :: default ())
70+ . build ()
71+ }
72+ ```
73+
74+
5075## Axum Support
5176The trace context propagated from other services needs to be extracted and injected
5277into the propagator. For ` axum ` , our choice of HTTP API framework, a third-party crate
0 commit comments