1616 import wrapt
1717 from fastapi import HTTPException
1818 from fastapi .exception_handlers import http_exception_handler
19+ from opentelemetry .semconv .trace import SpanAttributes
1920 from starlette .middleware import Middleware
2021
2122 from instana .instrumentation .asgi import InstanaASGIMiddleware
2223 from instana .log import logger
2324 from instana .util .gunicorn import running_in_gunicorn
2425 from instana .util .traceutils import get_tracer_tuple
2526
26- from opentelemetry .semconv .trace import SpanAttributes
27-
2827 if TYPE_CHECKING :
2928 from starlette .requests import Request
3029 from starlette .responses import Response
@@ -51,7 +50,7 @@ async def instana_exception_handler(
5150 _ , span , _ = get_tracer_tuple ()
5251
5352 if span :
54- if hasattr (exc , "detail" ) and 500 <= exc .status_code :
53+ if hasattr (exc , "detail" ) and exc .status_code >= 500 :
5554 span .set_attribute ("http.error" , exc .detail )
5655 span .set_attribute (SpanAttributes .HTTP_STATUS_CODE , exc .status_code )
5756 except Exception :
@@ -72,7 +71,7 @@ def init_with_instana(
7271 elif isinstance (middleware , list ):
7372 middleware .append (Middleware (InstanaASGIMiddleware ))
7473 elif isinstance (middleware , tuple ):
75- kwargs ["middleware" ] = (* middleware , Middleware (InstanaASGIMiddleware ))
74+ kwargs ["middleware" ] = (* middleware , Middleware (InstanaASGIMiddleware ))
7675 else :
7776 logger .warning ("Unsupported FastAPI middleware sequence type." )
7877
0 commit comments