Skip to content

Commit 02c3e7a

Browse files
jdmajorgreys
authored andcommitted
aiohttp: do not set query string in http.url tag (#923)
1 parent 4acfbd2 commit 02c3e7a

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

ddtrace/contrib/aiohttp/middlewares.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def on_prepare(request, response):
9999
request_span.resource = resource
100100
request_span.set_tag('http.method', request.method)
101101
request_span.set_tag('http.status_code', response.status)
102-
request_span.set_tag(http.URL, request.url)
102+
request_span.set_tag(http.URL, request.url.with_query(None))
103103
request_span.finish()
104104

105105

tests/contrib/aiohttp/test_middleware.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ def test_handler(self):
4646
assert '200' == span.get_tag('http.status_code')
4747
assert 0 == span.error
4848

49-
@unittest_run_loop
5049
@asyncio.coroutine
51-
def test_param_handler(self):
50+
def _test_param_handler(self, query_string=''):
51+
if query_string:
52+
fqs = '?' + query_string
53+
else:
54+
fqs = ''
5255
# it should manage properly handlers with params
53-
request = yield from self.client.request('GET', '/echo/team')
56+
request = yield from self.client.request('GET', '/echo/team' + fqs)
5457
assert 200 == request.status
5558
text = yield from request.text()
5659
assert 'Hello team' == text
@@ -64,6 +67,18 @@ def test_param_handler(self):
6467
assert str(self.client.make_url('/echo/team')) == span.get_tag(http.URL)
6568
assert '200' == span.get_tag('http.status_code')
6669

70+
@unittest_run_loop
71+
def test_param_handler(self):
72+
return self._test_param_handler()
73+
74+
@unittest_run_loop
75+
def test_query_string(self):
76+
return self._test_param_handler("foo=bar")
77+
78+
@unittest_run_loop
79+
def test_query_string_duplicate_keys(self):
80+
return self._test_param_handler("foo=bar&foo=baz&x=y")
81+
6782
@unittest_run_loop
6883
@asyncio.coroutine
6984
def test_404_handler(self):

0 commit comments

Comments
 (0)