Skip to content

Commit 4d4e44e

Browse files
committed
bot comments
1 parent 1fa438a commit 4d4e44e

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

sentry_sdk/integrations/tornado.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def _handle_request_impl(self: "RequestHandler") -> "Generator[None, None, None]
169169
).items():
170170
span.set_attribute(attr, value)
171171

172+
with capture_internal_exceptions():
172173
method = getattr(self, self.request.method.lower(), None)
173174
if method is not None:
174175
span_name = transaction_from_function(method)
@@ -179,6 +180,7 @@ def _handle_request_impl(self: "RequestHandler") -> "Generator[None, None, None]
179180
SegmentSource.COMPONENT,
180181
)
181182

183+
with capture_internal_exceptions():
182184
status_int = self.get_status()
183185
span.set_attribute(SPANDATA.HTTP_STATUS_CODE, status_int)
184186
span.status = "error" if status_int >= 400 else "ok"
@@ -195,13 +197,9 @@ def _get_request_attributes(request: "Any") -> "Dict[str, Any]":
195197
attributes[f"{SPANDATA.HTTP_REQUEST_HEADER}.{header.lower()}"] = value
196198

197199
if request.query:
198-
attributes[SPANDATA.HTTP_QUERY] = request.query
200+
attributes[SPANDATA.URL_QUERY] = request.query
199201

200-
attributes[SPANDATA.URL_FULL] = "%s://%s%s" % (
201-
request.protocol,
202-
request.host,
203-
request.path,
204-
)
202+
attributes[SPANDATA.URL_FULL] = request.full_url()
205203

206204
if request.protocol:
207205
attributes[SPANDATA.NETWORK_PROTOCOL_NAME] = request.protocol

tests/integrations/tornado/test_tornado.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_transactions(
142142
request_headers = dict(span.iter_headers())
143143

144144
response = client.fetch(
145-
"/hi", method="POST", body=b"heyoo", headers=request_headers
145+
"/hi?foo=bar", method="POST", body=b"heyoo", headers=request_headers
146146
)
147147
assert response.code == code
148148

@@ -178,6 +178,9 @@ def test_transactions(
178178
assert server_segment["attributes"]["http.request.method"] == "POST"
179179
assert server_segment["attributes"]["http.request.body.data"] == "heyoo"
180180
assert server_segment["attributes"]["http.response.status_code"] == code
181+
assert server_segment["attributes"]["url.query"] == "foo=bar"
182+
assert server_segment["attributes"]["url.full"].endswith("/hi?foo=bar")
183+
assert server_segment["attributes"]["url.full"].startswith("http://")
181184
assert server_segment["status"] == ("ok" if code == 200 else "error")
182185
assert client_segment["trace_id"] == server_segment["trace_id"]
183186
else:
@@ -225,7 +228,7 @@ def test_transactions(
225228
**request["headers"],
226229
},
227230
"method": "POST",
228-
"query_string": "",
231+
"query_string": "foo=bar",
229232
"data": {"heyoo": [""]},
230233
"url": "http://{host}/hi".format(host=host),
231234
}

0 commit comments

Comments
 (0)