Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions sentry_sdk/integrations/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,15 @@ async def sentry_app_handle(

url_attributes = {}
if should_send_default_pii():
url_attributes["url.full"] = "%s://%s%s" % (
url_full = "%s://%s%s" % (
request.scheme,
request.host,
request.path,
)
if request.query_string:
url_full += "?" + request.query_string

url_attributes["url.full"] = url_full
url_attributes["url.path"] = request.path

if request.query_string:
Expand Down Expand Up @@ -362,7 +366,13 @@ async def on_request_start(
"http.request.method": method,
}
if parsed_url is not None and should_send_default_pii():
attributes["url.full"] = parsed_url.url
url_full = parsed_url.url
if parsed_url.query:
url_full += "?" + parsed_url.query
if parsed_url.fragment:
url_full += "#" + parsed_url.fragment

attributes["url.full"] = url_full
attributes["url.path"] = params.url.path

if parsed_url.query:
Expand Down
16 changes: 14 additions & 2 deletions sentry_sdk/integrations/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ def send(self: "Client", request: "Request", **kwargs: "Any") -> "Response":
attributes: "Attributes" = {}

if parsed_url is not None and should_send_default_pii():
attributes["url.full"] = parsed_url.url
url_full = parsed_url.url
if parsed_url.query:
url_full += "?" + parsed_url.query
if parsed_url.fragment:
url_full += "#" + parsed_url.fragment

attributes["url.full"] = url_full
if parsed_url.query:
attributes["url.query"] = parsed_url.query
if parsed_url.fragment:
Expand Down Expand Up @@ -162,7 +168,13 @@ async def send(
attributes: "Attributes" = {}

if parsed_url is not None and should_send_default_pii():
attributes["url.full"] = parsed_url.url
url_full = parsed_url.url
if parsed_url.query:
url_full += "?" + parsed_url.query
if parsed_url.fragment:
url_full += "#" + parsed_url.fragment

attributes["url.full"] = url_full
if parsed_url.query:
attributes["url.query"] = parsed_url.query
if parsed_url.fragment:
Expand Down
16 changes: 14 additions & 2 deletions sentry_sdk/integrations/httpx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ def send(self: "Client", request: "Request", **kwargs: "Any") -> "Response":
attributes: "Attributes" = {}

if parsed_url is not None and should_send_default_pii():
attributes["url.full"] = parsed_url.url
url_full = parsed_url.url
if parsed_url.query:
url_full += "?" + parsed_url.query
if parsed_url.fragment:
url_full += "#" + parsed_url.fragment

attributes["url.full"] = url_full
if parsed_url.query:
attributes["url.query"] = parsed_url.query
if parsed_url.fragment:
Expand Down Expand Up @@ -164,7 +170,13 @@ async def send(
attributes: "Attributes" = {}

if parsed_url is not None and should_send_default_pii():
attributes["url.full"] = parsed_url.url
url_full = parsed_url.url
if parsed_url.query:
url_full += "?" + parsed_url.query
if parsed_url.fragment:
url_full += "#" + parsed_url.fragment

attributes["url.full"] = url_full
if parsed_url.query:
attributes["url.query"] = parsed_url.query
if parsed_url.fragment:
Expand Down
5 changes: 4 additions & 1 deletion sentry_sdk/integrations/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ def _get_request_attributes(
if path:
attributes["url.path"] = path

attributes["url.full"] = get_request_url(environ, use_x_forwarded_for)
url_full = get_request_url(environ, use_x_forwarded_for)
if query_string:
url_full += "?" + query_string
attributes["url.full"] = url_full

return attributes
4 changes: 1 addition & 3 deletions tests/integrations/aiohttp/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,10 +1540,8 @@ async def hello(request):

url_full = inner_client_span["attributes"]["url.full"]

# parse_url() splits the URL — url.full is the base URL only, with the
# query string captured separately on url.query.
assert url_full.startswith("http://127.0.0.1:")
assert url_full.endswith("/")
assert "?foo=bar" in url_full

assert inner_client_span["attributes"]["url.path"] == "/"

Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/httpx/test_httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ def test_http_url_attributes_span_streaming(
assert http_span["attributes"]["http.response.status_code"] == 200

if send_default_pii:
assert http_span["attributes"]["url.full"] == "http://example.com/"
assert http_span["attributes"]["url.full"] == "http://example.com/?foo=bar#frag"
assert http_span["attributes"]["url.query"] == "foo=bar"
assert http_span["attributes"]["url.fragment"] == "frag"
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/httpx2/test_httpx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ def test_http_url_attributes_span_streaming(
http_span = _get_http_client_span(items)

assert http_span["attributes"]["http.request.method"] == "GET"
assert http_span["attributes"]["url.full"] == "http://example.com/"
assert http_span["attributes"]["url.full"] == "http://example.com/?foo=bar#frag"
assert http_span["attributes"]["url.query"] == "foo=bar"
assert http_span["attributes"]["url.fragment"] == "frag"
assert http_span["attributes"]["http.response.status_code"] == 200
Expand Down
5 changes: 4 additions & 1 deletion tests/integrations/wsgi/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ def dogpark(environ, start_response):
assert span["status"] == "ok"

if send_pii:
assert span["attributes"]["url.full"] == "http://localhost/dogs/are/great"
assert (
span["attributes"]["url.full"]
== "http://localhost/dogs/are/great?toy=tennisball"
)
assert span["attributes"]["url.path"] == "/dogs/are/great"
assert span["attributes"]["http.query"] == "toy=tennisball"
else:
Expand Down
Loading