fastrace-reqwest
Distributed tracing integration for reqwest HTTP client requests with fastrace.
Overview
fastrace-reqwest provides automatic trace context propagation for HTTP requests made with the reqwest client. It works seamlessly with the fastrace library to extract and inject trace context into outgoing requests.
What is Context Propagation?
Context propagation is a fundamental concept in distributed tracing that enables the correlation of operations spanning multiple services. When a request moves from one service to another, trace context information needs to be passed along, ensuring that all operations are recorded as part of the same trace.
fastrace-reqwest implements the W3C Trace Context standard for propagating trace information between services. This ensures compatibility with other tracing systems that follow the same standard.
Features
- 🔄 Automatic Context Propagation: Automatically inject trace context into outgoing HTTP requests.
- 🌉 Seamless Integration: Works seamlessly with the
fastracelibrary for complete distributed tracing. - 📊 Full Compatibility: Works with fastrace's collection and reporting capabilities.
Installation
Add to your Cargo.toml:
[]
= "0.7"
= "0.2"
Usage
HTTP Client
use *;
use traceparent_headers;
use Client;
async
How It Works
fastrace-reqwest enables automatic propagation of trace context between services by:
- Extracting the current trace context from the calling function.
- Formatting it according to the W3C Trace Context specification.
- Injecting it into outgoing HTTP requests as headers
- Working seamlessly with the companion
fastrace-poemlibrary (or other compatible frameworks) to extract the context on the receiving end.
Complete Example
Check out the examples directory for complete working examples showing:
client.rs- How to send requests with trace context.server.rs- How to receive and process trace context usingfastrace-poem.
To run the examples:
# First start the server
# Then in another terminal, run the client
How It Works
- When making an HTTP request,
traceparent_headers()checks for a current span context. - If found, it encodes the context as a
traceparentHTTP header following the W3C standard. - The receiving service extracts this header and continues the trace.
License
This project is licensed under the Apache-2.0 license.