@@ -514,7 +514,7 @@ def process_response(self, req, resp, resource, req_succeeded=None): # pylint:d
514514
515515 status = resp .status
516516 if resource is None :
517- status = "404"
517+ status = falcon . HTTP_404
518518 else :
519519 exc_type , exc = None , None
520520 if _ENVIRON_EXC in req .env :
@@ -523,37 +523,39 @@ def process_response(self, req, resp, resource, req_succeeded=None): # pylint:d
523523
524524 if exc_type and not req_succeeded :
525525 if "HTTPNotFound" in exc_type .__name__ :
526- status = "404"
526+ status = falcon . HTTP_404
527527 elif isinstance (exc , (falcon .HTTPError , falcon .HTTPStatus )):
528528 try :
529- status = exc .title .split (" " )[0 ]
529+ if _falcon_version > 2 :
530+ status = falcon .code_to_http_status (exc .status )
531+ else :
532+ status = exc .status
530533 except ValueError :
531- status = "500"
534+ status = falcon . HTTP_500
532535 else :
533- status = "500"
536+ status = falcon .HTTP_500
537+
538+ # Falcon 1 does not support response headers. So
539+ # send an empty dict.
540+ response_headers = {}
541+ if _falcon_version > 1 :
542+ response_headers = resp .headers
543+
544+ otel_wsgi .add_response_attributes (
545+ span ,
546+ status ,
547+ response_headers ,
548+ req_attrs ,
549+ self ._sem_conv_opt_in_mode ,
550+ )
534551
535- status_code = status .split (" " )[0 ]
552+ if (
553+ _report_new (self ._sem_conv_opt_in_mode )
554+ and req .uri_template
555+ and req_attrs is not None
556+ ):
557+ req_attrs [HTTP_ROUTE ] = req .uri_template
536558 try :
537- set_status_code (
538- span ,
539- status_code ,
540- req_attrs ,
541- sem_conv_opt_in_mode = self ._sem_conv_opt_in_mode ,
542- )
543-
544- if (
545- _report_new (self ._sem_conv_opt_in_mode )
546- and req .uri_template
547- and req_attrs is not None
548- ):
549- req_attrs [HTTP_ROUTE ] = req .uri_template
550-
551- # Falcon 1 does not support response headers. So
552- # send an empty dict.
553- response_headers = {}
554- if _falcon_version > 1 :
555- response_headers = resp .headers
556-
557559 if span .is_recording () and span .kind == trace .SpanKind .SERVER :
558560 # Check if low-cardinality route is available as per semantic-conventions
559561 if req .uri_template :
0 commit comments