Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use reqwest client with tracing? #728

Open
paymog opened this issue Apr 23, 2024 · 0 comments
Open

How to use reqwest client with tracing? #728

paymog opened this issue Apr 23, 2024 · 0 comments

Comments

@paymog
Copy link

paymog commented Apr 23, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant