You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rewrite FastAPI instrumentor middleware stack to be failsafe (#3664)
* rewrite FastAPIInstrumentor:build_middleware_stack to become failsafe
* add test cases for FastAPI failsafe handling
* add CHANGELOG entry
* remove unused import
* [lint] don't return from failsafe wrapper
* [lint] allow broad exceptions
* [lint] more allowing
* record FastAPI hook exceptions in active span
* remove comment
* properly deal with hooks not being set
* add custom FastAPI exception recording
* move failsafe hook handling down to OpenTelemetryMiddleware
* shut up pylint
* optimize failsafe to check for `None` only once
* remove confusing comment and simplify wrapper logic
* add clarifying comment
* test proper exception / status code recording
* add HTTP status code check
* test HTTP status on the exception recording span
* improve test by removing TypeError
* rectify comment/explanation on inner middleware for exception handling
* minor typo
* move ExceptionHandlingMiddleware as the outermost inner middleware
Also improve code documentation and add another test.
* use distinct status code in test
* improve comemnt
Co-authored-by: Alex Hall <[email protected]>
* narrow down exception handling
Co-authored-by: Alex Hall <[email protected]>
* narrow down FastAPI exception tests to relevant spans
* collapse tests, more narrow exceptions
* move failsafe hook tests to ASGI test suite
* update CHANGELOG
* satisfy linter
* don't record exception if span is not recording
* add test for unhappy instrumentation codepath
* make inject fixtures private
* give up and shut up pylint
* improve instrumentation failure error message and add test
---------
Co-authored-by: Alex Hall <[email protected]>
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py
0 commit comments