Skip to content

Instrumentation not working with HTTPX 0.21.1 async client #818

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

Closed
jlugao opened this issue Nov 29, 2021 · 7 comments
Closed

Instrumentation not working with HTTPX 0.21.1 async client #818

jlugao opened this issue Nov 29, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@jlugao
Copy link

jlugao commented Nov 29, 2021

Describe your environment

I am using python 3.9 and

   9   │ httpx==0.21.1
  11   │ opentelemetry-api==1.7.1
  12   │ opentelemetry-exporter-jaeger==1.7.1
  13   │ opentelemetry-exporter-jaeger-proto-grpc==1.7.1
  14   │ opentelemetry-exporter-jaeger-thrift==1.7.1
  15   │ opentelemetry-instrumentation==0.26b1
  16   │ opentelemetry-instrumentation-httpx==0.26b1
  17   │ opentelemetry-sdk==1.7.1
  18   │ opentelemetry-semantic-conventions==0.26b1

Steps to reproduce
clone https://github.com/jlugao/httpx-opentelemetry-bug
pip install requirements.txt
python sample.py

What is the expected behavior?
It should print 200 and send data to jaeger

What is the actual behavior?

    response = await transport.handle_async_request(request)
TypeError: handle_async_request() missing 1 required positional argument: 'url' 

Additional context
This is a small script that I did to reproduce an error happening in an app that is running on docker and fastapi.

@jlugao jlugao added the bug Something isn't working label Nov 29, 2021
@jlugao
Copy link
Author

jlugao commented Jan 5, 2022

can anyone help me out with this? I'd be happy to create a PR for this if I have some guidance on what should I look for in the codebase

@ocelotl
Copy link
Contributor

ocelotl commented Jan 7, 2022

It seems like the this call uses a single request argument while our instrumentation for httpx expects method and url as arguments.

I ran your code in a virtual environment and modified httpx _client.py (around line 1702) file to this:

       with request_context(request=request):
            response = await transport.handle_async_request(
                request.method.encode("utf-8"), request.url
            )

After that, your code continues to run and fails later with another error. Maybe what is needed is a change in the httpx instrumentation to extract method and url from the request object?

@jianyuan
Copy link

jianyuan commented Jan 7, 2022

I believe it's caused by this change: encode/httpx#1840. The latest version of httpx that is compatible with this library is 0.19.0.

@ruimartinsptl
Copy link

I think that it was solved here: #866

@ocelotl
Copy link
Contributor

ocelotl commented Feb 28, 2022

I think that it was solved here: #866

@jlugao can you confirm, please?

@tuchandra
Copy link

tuchandra commented Apr 4, 2022

FWIW I can't reproduce this with opentelemetry-instrumentation-httpx = "^0.29b0"

@lzchen
Copy link
Contributor

lzchen commented Apr 5, 2022

@jlugao
Will be closing the issue for now. Feel free to open back up if you are still having issues.

@lzchen lzchen closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants