Skip to content

Commit c44244c

Browse files
author
Filip Nikolovski
committed
fix exceptions to not be masked as 500 on every thrown exception
1 parent b941569 commit c44244c

File tree

1 file changed

+9
-2
lines changed
  • instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon

1 file changed

+9
-2
lines changed

instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,21 @@ def process_response(self, req, resp, resource, req_succeeded=None): # pylint:d
516516
if resource is None:
517517
status = "404"
518518
else:
519+
exc_type, exc = None, None
519520
if _ENVIRON_EXC in req.env:
520521
exc = req.env[_ENVIRON_EXC]
521522
exc_type = type(exc)
522-
else:
523-
exc_type, exc = None, None
523+
524524
if exc_type and not req_succeeded:
525525
if "HTTPNotFound" in exc_type.__name__:
526526
status = "404"
527+
elif isinstance(exc, falcon.HTTPError) or isinstance(
528+
exc, falcon.HTTPStatus
529+
):
530+
try:
531+
status = exc.title.split(" ")[0]
532+
except ValueError:
533+
status = "500"
527534
else:
528535
status = "500"
529536

0 commit comments

Comments
 (0)