Skip to content

Commit ce8480c

Browse files
committed
[pylons] catch 500s
1 parent 3abb228 commit ce8480c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ddtrace/contrib/pylons/middleware.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __call__(self, environ, start_response):
2727
if not span.sampled:
2828
return self.app(environ, start_response)
2929

30+
# tentative on status code, otherwise will be caught by except below
3031
def _start_response(status, *args, **kwargs):
3132
""" a patched response callback which will pluck some metadata. """
3233
http_code = int(status.split()[0])
@@ -37,6 +38,12 @@ def _start_response(status, *args, **kwargs):
3738

3839
try:
3940
return self.app(environ, _start_response)
41+
except Exception as e:
42+
# "unexpected errors"
43+
# exc_info set by __exit__ on current tracer
44+
span.set_tag(http.STATUS_CODE, getattr(e, 'code', 500))
45+
span.error = 1
46+
raise
4047
finally:
4148
controller = environ.get('pylons.routes_dict', {}).get('controller')
4249
action = environ.get('pylons.routes_dict', {}).get('action')

0 commit comments

Comments
 (0)