8000 How to use reqwest client with tracing? · Issue #728 · tomusdrw/rust-web3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
How to use reqwest client with tracing? #728
Open
@paymog

Description

@paymog

I'd like to add OTLP tracing to my outgoing web3 requests. I currently make

        let client = reqwest::Client::builder()
            .default_headers(headers)
            .build()
            .unwrap();

        Transport::RPC {
            client: http::Http::with_client(client, rpc),
            metrics,
            provider: provider.as_ref().into(),
        }

I'd like to instead use the ClientWithMiddleware object returned by this crate

        let client = ClientBuilder::new(
            reqwest::Client::builder()
                .default_headers(headers)
                .build()
                .unwrap(),
        )
        .with(TracingMiddleware::default())
        .build();

        Transport::RPC {
            client: http::Http::with_client(client, rpc),
            metrics,
            provider: provider.as_ref().into(),
        }

but Http::with_client will only accept an object of type Client and not ClientWithMiddleware. Is there a way to get around this considering that ClientWithMiddleware should expose the exact same API?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0