reqwest-middleware/reqwest-tracing
Luca Palmieri a92e19d638 (cargo-release) start next development iteration 0.1.2-alpha.0 2021-08-30 13:17:31 +02:00
..
src Add support for OpenTelemetry 0.16 and tracing-opentelemetry 0.15 (#2) 2021-08-30 13:14:06 +02:00
CHANGELOG.md Initial commit 2021-08-13 08:59:58 +01:00
Cargo.toml (cargo-release) start next development iteration 0.1.2-alpha.0 2021-08-30 13:17:31 +02:00
README.md Add support for OpenTelemetry 0.16 and tracing-opentelemetry 0.15 (#2) 2021-08-30 13:14:06 +02:00

README.md

reqwest-tracing

Opentracing middleware implementation for reqwest-middleware.

Crates.io Docs.rs CI Coverage Status

Overview

Attach TracingMiddleware to your client to automatically trace HTTP requests:

use opentelemetry::exporter::trace::stdout;
use reqwest_middleware::ClientBuilder;
use reqwest_tracing::TracingMiddleware;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::Registry;

#[tokio::main]
async fn main() {
  let (tracer, _) = stdout::new_pipeline().install();
  let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
  let subscriber = Registry::default().with(telemetry);
  tracing::subscriber::set_global_default(subscriber).unwrap();

  run().await;
}

async fun run() {
  let client = ClientBuilder::new(reqwest::Client::new())
    .with(TracingMiddleware)
    .build();`

  client.get("https://truelayer.com").send().await.unwrap();
}

See the tracing crate for more information on how to set up a tracing subscriber to make use of the spans.

How to install

Add reqwest-tracing to your dependencies. Optionally enable opentelemetry integration by enabling an opentelemetry version feature:

[dependencies]
# ...
reqwest-tracing = { version = "0.1.0", features = ["opentelemetry_0_16"] }

Available opentelemetry features are opentelemetry_0_16, opentelemetry_0_15, opentelemetry_0_14 and opentelemetry_0_13.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.