#tracing #awc

tracing-awc

Tracing instrumentation for the awc http client

33 releases

0.1.9 Nov 13, 2023
0.1.7 May 24, 2023
0.1.6 Sep 21, 2022
0.1.5 Apr 7, 2022
0.1.0-beta.10 Nov 25, 2021

#628 in Asynchronous

Download history 205/week @ 2023-10-30 141/week @ 2023-11-06 261/week @ 2023-11-13 286/week @ 2023-11-20 288/week @ 2023-11-27 226/week @ 2023-12-04 212/week @ 2023-12-11 166/week @ 2023-12-18 139/week @ 2023-12-25 88/week @ 2024-01-01 197/week @ 2024-01-08 210/week @ 2024-01-15 58/week @ 2024-01-22 241/week @ 2024-01-29 87/week @ 2024-02-05 222/week @ 2024-02-12

632 downloads per month
Used in 2 crates

AGPL-3.0

34KB
327 lines

tracing-awc

Instrument the AWC client with tracing, and optionally opentelemetry for propagating OpenTelemetry spans

Usage

actix-rt = "2.6"
awc = "3.0.0"
tracing = "0.1"
tracing-futures = "0.2"
tracing-subscriber = { version = "0.2", features = ["fmt"] }
tracing-awc = { version = "0.1.0", features = ["opentelemetry_0_17"]
use awc::Client;
use std::error::Error;
use tracing_awc::{root_span, Tracing};
use tracing_futures::Instrument;

async fn request(url: &str) -> Result<(), Box<dyn Error>> {
    Client::builder()
        .wrap(Tracing)
        .finish()
        .get(url)
        .send()
        .await?;

    Ok(())
}

#[actix_rt::main]
async fn main() -> Result<(), Box<dyn Error>> {
    init_opentelemetry("http://localhost:4317")?;

    request("http://localhost:9000")
        .instrument(root_span())
        .await
}

// See examples/client.rs for an implementation of init_opentelemetry

Contributing

Feel free to open issues for anything you find an issue with. Please note that any contributed code will be licensed under the AGPLv3.

License

Copyright © 2021 Riley Trautman

tracing-awc-opentelemetry is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

tracing-awc-opentelemetry is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This file is part of tracing-awc-opentelemetry.

You should have received a copy of the GNU General Public License along with tracing-awc-opentelemetry. If not, see http://www.gnu.org/licenses/.

Dependencies

~13–26MB
~434K SLoC