Skip to content

Releases: stephenhillier/starlette_exporter

v0.23.0

26 Jun 04:06
Compare
Choose a tag to compare

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.

v0.22.0

29 May 04:16
dc88ee9
Compare
Choose a tag to compare
  • 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:
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.

v0.21.0

12 Feb 05:11
c44e3d5
Compare
Choose a tag to compare

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

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.

Thank you @backbord (#92)!

v0.20.0

06 Feb 16:24
Compare
Choose a tag to compare

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.

v0.19.0

21 Jan 06:11
Compare
Choose a tag to compare

Support for uvicorn v0.26.0's updated root_path behavior (see encode/uvicorn#2213). @dolfinus

v0.18.0

17 Jan 06:28
9810ec3
Compare
Choose a tag to compare

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

v0.17.1

11 Nov 06:34
Compare
Choose a tag to compare

Add FutureWarnings for group_paths and filter_unhandled_paths indicating that the default values will change next release (see #79 )

v0.17.0

11 Nov 06:29
Compare
Choose a tag to compare

Changes for v0.17.0:

  • include headers in app scope when matching request path #76 @evstratbg
  • callback functions used to populate labels can now be async #70 @YiuRULE

Potentially impactful changes:

  • the status code reported for client disconnections will now be 499 instead of 500 #77 @Alexander-N
    • note: some users may notice a new status_code=499 timeseries if a client disconnects before response is written (previously this would be erroneously reported as a 500 status).

Optionally skip methods

05 May 18:03
Compare
Choose a tag to compare

v0.16.0

skip_methods option

This releases adds the skip_methods option, which allows you to avoid recording metrics for any requests with the specified methods. Use this if you do not want certain types of requests (e.g. OPTIONS) to appear in your metrics. The argument should be a list of strings corresponding to method names.

Usage:

app.add_middleware(
  PrometheusMiddleware,
  app_name="hello_world",
  skip_methods=['OPTIONS']
)

Credit to @adinsoon for this new feature.

Bug fixes

Fix for Module "starlette_exporter" does not explicitly export attribute "PrometheusMiddleware" (#63) @poofeg

README fixes: fixed references to the handle_metrics function in example (@elatomo ), and fixed the exemplars example (@camerondavison)

update type hint for buckets param

20 Jan 07:12
Compare
Choose a tag to compare

This small release updates the type hint for the buckets param from List to Sequence to match the type hint in the Prometheus client library.
Credit to @sbrandtb (#59)