Skip to content

Commit 9af1c94

Browse files
authored
Merge pull request #69 from DataDog/matt/pylons
trace/pylons: allow users to set resources inside of handlers
2 parents f377044 + fd4b0f6 commit 9af1c94

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ddtrace/contrib/pylons/middleware.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ def _start_response(status, *args, **kwargs):
4747
finally:
4848
controller = environ.get('pylons.routes_dict', {}).get('controller')
4949
action = environ.get('pylons.routes_dict', {}).get('action')
50-
span.resource = "%s.%s" % (controller, action)
50+
51+
# There are cases where users re-route requests and manually
52+
# set resources. If this is so, don't do anything, otherwise
53+
# set the resource to the controller / action that handled it.
54+
if span.resource == span.name:
55+
span.resource = "%s.%s" % (controller, action)
5156

5257
span.set_tags({
5358
http.METHOD: environ.get('REQUEST_METHOD'),

0 commit comments

Comments
 (0)