Crates.io | fastrace-reqwest |
lib.rs | fastrace-reqwest |
version | 0.2.0 |
created_at | 2025-03-18 11:53:05.14888+00 |
updated_at | 2025-05-13 16:39:09.762504+00 |
description | A reqwest util for propagating trace context for fastrace |
homepage | |
repository | https://github.com/fast/fastrace-reqwest |
max_upload_size | |
id | 1596529 |
size | 59,902 |
Distributed tracing integration for reqwest HTTP client requests with fastrace.
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.
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.
fastrace
library for complete distributed tracing.Add to your Cargo.toml
:
[dependencies]
fastrace = "0.7"
fastrace-reqwest = "0.2"
use fastrace::prelude::*;
use fastrace_reqwest::traceparent_headers;
use reqwest::Client;
#[fastrace::trace]
async fn send_request() {
let client = Client::new();
// Add trace context headers to your request.
let response = client
.get("https://api.example.com/data")
.headers(traceparent_headers())
.send()
.await
.unwrap();
// Process response...
}
fastrace-reqwest
enables automatic propagation of trace context between services by:
fastrace-poem
library (or other compatible frameworks) to extract the context on the receiving end.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 using fastrace-poem
.To run the examples:
# First start the server
cargo run --example server
# Then in another terminal, run the client
cargo run --example client
traceparent_headers()
checks for a current span context.traceparent
HTTP header following the W3C standard.This project is licensed under the Apache-2.0 license.