Major release with a single breaking change: Python 3.7 is not supported anymore. Beyond that, three improvements based on various pull requests.
Added
-
Instrumentator now works without FastAPI. This is possible because every FastAPI app is also a Starlette app (but not the other way around). Or to be more specific: FastAPI uses Starlette for things like routing and middleware this package relies on. The change is backwards compatible, even type checkers like mypy should continue working. Thanks to @mvanderlee for proposing this in #280 and implementing it in #288.
-
Middleware also records duration without streaming in addition to the already existing total latency (i.e. the time consumed for streaming is not included in the duration value). The differentiation can be valuable as it shows the time to first byte.
This mode is opt-in and can be enabled / used in several ways: The
Instrumentator()
constructor, themetrics.default()
closure, and themetrics.latency()
closure now come with the flagshould_exclude_streaming_duration
. The attributemodified_duration_without_streaming
has been added to themetrics.Info
class. Instances ofmetrics.Info
are passed to instrumentation functions, where the added value can be used to set metrics.Thanks to @dosuken123 for proposing this in #291 and implementing it in #290.
-
Relaxed type of
get_route_name()
argument toHTTPConnection
. This allows developers to use theget_route_name
function for getting the name of websocket routes as well. Thanks to @pajowu for proposing and implementing this feature in #276.
Removed
- BREAKING: Dropped support for Python 3.7 which is has reached end-of-life.