Skip to content

Commit 4acfbd2

Browse files
jdmajorgreys
authored andcommitted
tornado: do not include query string in the http.url tag (#922)
The query string used to be included in http.url tag for Tornado. Let's match the behavior of other frameworks and remove it.
1 parent 4de8902 commit 4acfbd2

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

ddtrace/contrib/tornado/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def on_finish(func, handler, args, kwargs):
6767
request_span.resource = '{}.{}'.format(klass.__module__, klass.__name__)
6868
request_span.set_tag('http.method', request.method)
6969
request_span.set_tag('http.status_code', handler.get_status())
70-
request_span.set_tag('http.url', request.full_url())
70+
request_span.set_tag(http.URL, request.full_url().rsplit('?', 1)[0])
7171
request_span.finish()
7272

7373
return func(*args, **kwargs)

tests/contrib/tornado/test_safety.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_arbitrary_resource_querystring(self):
9999

100100
request_span = traces[0][0]
101101
assert 'tests.contrib.tornado.web.app.SuccessHandler' == request_span.resource
102-
assert self.get_url('/success/?magic_number=42') == request_span.get_tag(http.URL)
102+
assert self.get_url('/success/') == request_span.get_tag(http.URL)
103103

104104
def test_arbitrary_resource_404(self):
105105
# users inputs should not determine `span.resource` field

tests/contrib/tornado/test_tornado_web.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ class TestTornadoWeb(TornadoTestCase):
1212
"""
1313
Ensure that Tornado web handlers are properly traced.
1414
"""
15-
def test_success_handler(self):
15+
def test_success_handler(self, query_string=''):
1616
# it should trace a handler that returns 200
17-
response = self.fetch('/success/')
17+
if query_string:
18+
fqs = '?' + query_string
19+
else:
20+
fqs = ''
21+
response = self.fetch('/success/' + fqs)
1822
assert 200 == response.code
1923

2024
traces = self.tracer.writer.pop_traces()
@@ -31,6 +35,9 @@ def test_success_handler(self):
3135
assert self.get_url('/success/') == request_span.get_tag(http.URL)
3236
assert 0 == request_span.error
3337

38+
def test_success_handler_query_string(self):
39+
self.test_success_handler('foo=bar')
40+
3441
def test_nested_handler(self):
3542
# it should trace a handler that calls the tracer.trace() method
3643
# using the automatic Context retrieval

0 commit comments

Comments
 (0)