Starlette-exporter

Latest version: v0.23.0

Safety actively analyzes 683322 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 5

0.23.0

Features

Group unhandled paths

You can now get metrics on requests made against unhandled paths (i.e. 404s) using the `group_unhandled_paths` option. When this option is set, metrics for unhandled requests will be grouped under the `path="__unknown__"` label. From the README:

`group_unhandled_paths`: Similar to `filter_unhandled_paths`, but instead of ignoring the requests, they are grouped under the `__unknown__` path. This option overrides `filter_unhandled_paths` by setting it to `False`. The default value is `False`.

All credit to piotrhyzy and Filipoliko!

Bug fixes:

* Fixed a Prometheus client exception that could occur when using the `from_response_header` helper function to create custom labels. Thanks to lainiwa for reporting an issue.

0.22.0

* `from_response_header`: a new helper function for adding metric series labels based on HTTP response header values. See the README for more info. Example:

python
from starlette_exporter import PrometheusMiddleware, from_header, from_response_header

app.add_middleware(
PrometheusMiddleware,
labels={
"cache": from_response_header("X-FastAPI-Cache", allowed_values=("hit", "miss"))
}
)


Feedback and bug reports welcome - please open an issue.

0.21.0

You can now access the Request object from an exemplars callback. Example:

python
def exemplars(r: Request):
return {"trace_id": r.headers.get("x-trace-id", "")}

app.add_middleware(
PrometheusMiddleware,
exemplars=exemplars
)


This will allow you to use header values as exemplars. Note that if you want to use OpenTelemetry traces with exemplars, see [this example](https://github.com/stephenhillier/starlette_exporter/issues/90#issuecomment-1913465367).

Thank you backbord (92)!

0.20.0

the `skip_paths` option now accepts regular expressions. 89 bunny-therapist

**Notice:** most usage of skip_paths should be compatible with regex. If your usage is affected by this change, please update to a regular expression or file an issue.

0.19.0

Support for uvicorn v0.26.0's updated root_path behavior (see https://github.com/encode/uvicorn/pull/2213). dolfinus

0.18.0

Changes:
* Fix for handling for `root_path` (see 75 and 81) dolfinus
* Minimum Starlette version now 0.35 and dropped support for Python 3.7 83 dolfinus


Breaking changes:
* `group_paths` and `filter_unhandled_paths` now default to True. See 78 and 79

Page 1 of 5

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.