Skip to content

Incompatibility introduced in HTTPX 0.23.1 #4593

@burritoatspoton

Description

@burritoatspoton

Summary of problem

HTTPX 0.23.1 introduced a breaking change (https://github.com/encode/httpx/pull/2241/files#diff-f1eb4e8fbdbce3bb7dcc3ecb662f690f9443599de8b172513ddb65de6b1d7c73L325-L339) by removing a property that ddtrace relies on (https://github.com/DataDog/dd-trace-py/blob/1.x/ddtrace/contrib/httpx/patch.py#L42).

Which version of dd-trace-py are you using?

1.6.1

Which version of pip are you using?

22.3.1

Which libraries and their versions are you using?

`pip freeze` anyio==3.6.2 attrs==22.1.0 bytecode==0.13.0 cattrs==22.2.0 certifi==2022.9.24 ddsketch==2.0.4 ddtrace==1.6.1 envier==0.4.0 exceptiongroup==1.0.4 h11==0.14.0 httpcore==0.16.1 httpx==0.23.1 idna==3.4 jsonschema==4.17.0 packaging==21.3 protobuf==4.21.9 pyparsing==3.0.9 pyrsistent==0.19.2 rfc3986==1.5.0 six==1.16.0 sniffio==1.3.0 tenacity==8.1.0 typing_extensions==4.4.0 xmltodict==0.13.0

How can we reproduce your problem?

main.py

import httpx
httpx.get("https://google.com")

and then

$ ddtrace-run python main.py

What is the result that you get?

Traceback (most recent call last):
  File "/Users/burrito/tmp/main.py", line 3, in <module>
    httpx.get("https://google.com")
  File "/Users/burrito/tmp/env/lib/python3.10/site-packages/httpx/_api.py", line 189, in get
    return request(
  File "/Users/burrito/tmp/env/lib/python3.10/site-packages/httpx/_api.py", line 100, in request
    return client.request(
  File "/Users/burrito/tmp/env/lib/python3.10/site-packages/httpx/_client.py", line 821, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/Users/burrito/tmp/env/lib/python3.10/site-packages/ddtrace/contrib/httpx/patch.py", line 132, in _wrapped_sync_send
    _set_span_meta(span, req, resp)
  File "/Users/burrito/tmp/env/lib/python3.10/site-packages/ddtrace/contrib/httpx/patch.py", line 81, in _set_span_meta
    url=_url_to_str(request.url),
  File "/Users/burrito/tmp/env/lib/python3.10/site-packages/ddtrace/contrib/httpx/patch.py", line 42, in _url_to_str
    scheme, host, port, raw_path = url.raw
AttributeError: 'URL' object has no attribute 'raw'

What is the result that you expected?

Request performed and traces being sent correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions