Releases: stephenhillier/starlette_exporter
Option to ignore unhandled paths
This release grants the option to ignore unhandled paths. Use this option to prevent 404 errors from filling up the metrics. See #14.
From README:
filter_unhandled_paths
: setting this to True
will cause the middleware to ignore requests with unhandled paths (in other words, 404 errors). This helps prevent filling up the metrics with 404 errors and/or intentially bad requests. Default is False
.
example:
app.add_middleware(PrometheusMiddleware,
filter_unhandled_paths=True, group_paths=True)
Ability to set custom histogram buckets
This release adds a buckets
option, which accepts a list of numbers to use as buckets for the histogram. If not set (or set to None
), the Prometheus default will be used. (credit to @RyBo)
Convert to ASGI middleware
This release converts the starlette_exporter PrometheusMiddleware to be an ASGI middleware with a __call__
method instead of subclassing BaseHTTPMiddleware (add768e). This fixes an issue that prevents background tasks from being used with the middleware. See encode/starlette#919 (comment) for more information on the BaseHTTPMiddleware issue.
Other improvements:
- added
prefix
option, which allows developers to change the prefix of the exported metrics (previously, the metrics would always be prefixedstarlette_
, which remains the default). See issue #3. (b53bb3f) - switched to time.perf_counter() instead of
time.time()
for request times. (381a4be)
Credit for the improvements in this release goes to @rcoup.
Fix for mounted endpoints/apps when using group_paths
Fix for registry for when using multiprocess
Fixes multiprocess registry (#5 )
Application name included in metrics
The application name can now be specified when creating the middleware:
app.add_middleware(PrometheusMiddleware, app_name="my_app")
This allows filtering metrics by application if you have several FastAPI apps exporting metrics to the same Prometheus service.
Author: @paweldudzinski
v0.2.0 - Group metrics for apps/APIs by their http path
This version provides a group_paths
option to the PrometheusMiddleware constructor that will cause all metrics to be grouped by their router path.
This means that requests to endpoints with path variables like /api/v1/shop/1234
and /api/v1/shop/75
will appear in the metrics as /api/v1/shop/{item_id}
. This might be helpful if you want metrics organized by HTTP path but don't want them broken down by each individual item in a collection.
Initial PyPI release
Initial release of starlette_exporter
with request counter and request duration histogram. Both metrics include the HTTP method, path, and status code. Successful requests/errors can be separated by status code.