PackageTrack
Sign in Get early access

axum-prometheus

A tower middleware to collect and export HTTP metrics for Axum

0.10.1 5.1M downloads/mo #4473 most downloaded on crates.io Ptrskay3/axum-prometheus

What this package is like to depend on

Last release 23 days ago

31 Jul 2026

Ships fairly regularly

a new release about every 4 months

Most releases are documented

notes for 13 of 16 stable releases

Nothing withdrawn

no release was ever pulled

4 years old

16 releases · first in 2022

2 releases in the last 12 months

see the full history below

Release timeline

16 releases · Sep 2022 to Jul 2026
2023 2024 2025 2026
Release Pre-release

Releases

latest 16
  1. 0.10.1 31 Jul 2026
    Release notes

    What's Changed

    • release/0.10.1 by @Ptrskay3 in #90
    • fix: apply with_prefix on the layer-only build() path by @yacir in #91

    New Contributors

    • @yacir made their first contribution in #91

    Full Changelog: 0.10.0...0.10.1

    Open source →
    Release notes

    Fixed

    • with_prefix has no effect when finalizing with build() [#91]

    Changed

    • Bump various dependencies to latest versions.
    Open source →
  2. 0.10.0 03 Jan 2026
    Release notes

    What's Changed

    • Bump metrics-exporter-prometheus to 0.18.

    Full Changelog: 0.9.0...0.10.0

    Open source →
    Release notes

    Changed

    • Bump metrics-exporter-prometheus to 0.18.
    Open source →
  3. 0.9.0 13 Aug 2025
    Release notes

    What's Changed

    New Contributors

    Full Changelog: 0.8.0...0.9.0

    Open source →
    Release notes

    Changed

    • Add MetricLayerBuilder::with_allow_pattern and MetricLayerBuilder::with_allow_patterns to only report requests matching the given patterns. [#86]
    • Bump various outdated dependencies [#87]
    Open source →
  4. 0.8.0 04 Jan 2025
    Release notes

    0.8.0

    Changed

    • Compatibility with axum = "0.8". This also updates matchit to 0.8, changing how group patterns are described:
      for example, with_group_patterns_as("/foo", &["/foo/:bar"]) needs to be changed to with_group_patterns_as("/foo", &["/foo/{bar}"]).
      The metrics values are also impacted: for example, the value "/foo/:bar" is now "/foo/{bar}".
      This change bumps MSRV to 1.75. [#69]
    • Disable the default features in metrics-exporter-prometheus to skip the binding of port 9000, and the upkeep task is manually spawned. [#75]
    • Add a new feature http-listener to enable that exact feature in metrics-exporter-prometheus. [#79]
    • Replace the once_cell dependency with std::sync::OnceLock [#78]

    Fixed

    • Fixed the long-standing pending requests metric leak. [#74]
    • Removed the sideeffect of binding port 9000. [#75]
    Open source →
    Release notes

    Changed

    • Compatibility with axum = "0.8". This also updates matchit to 0.8, changing how group patterns are described: for example, with_group_patterns_as("/foo", &["/foo/:bar"]) needs to be changed to with_group_patterns_as("/foo", &["/foo/{bar}"]). The metrics values are also impacted: for example, the value "/foo/:bar" is now "/foo/{bar}". This change bumps MSRV to 1.75. [#69]
    • Disable the default features in metrics-exporter-prometheus to skip the binding of port 9000, and the upkeep task is manually spawned. [#75]
    • Add a new feature http-listener to enable that exact feature in metrics-exporter-prometheus. [#79]
    • Replace the once_cell dependency with std::sync::OnceLock [#78]

    Fixed

    • Fixed the long-standing pending requests metric leak. [#74]
    • Removed the sideeffect of binding port 9000. [#75]
    Open source →
  5. 0.7.0 20 Jul 2024
    Release notes

    Changed

    • MakeDefaultHandle::make_default_handle now takes self as argument. This allows custom implementor structs to hold non-static data. [#49]
    • Change the default initialization of PrometheusHandle to prevent unbounded memory growth of histograms. [#52]
    • Bump metrics to 0.23, metrics-exporter-prometheus to 0.15. [#52]
    • Document MSRV as 1.70 currently. [#52]

    Added

    • GenericMetricLayer::pair_from to initialize from a concrete struct. GenericMetricLayer::pair now requires that the handle type implements Default. [#49]
    • BaseMetricLayer that serves a more lightweight alternative to GenericMetricLayer. [#56]

    What's Changed

    New Contributors

    Full Changelog: 0.6.1...0.7.0

    Open source →
    Release notes

    Changed

    • MakeDefaultHandle::make_default_handle now takes self as argument. This allows custom implementor structs to hold non-static data. [#49]
    • Change the default initialization of PrometheusHandle to prevent unbounded memory growth of histograms. [#52]
    • Bump metrics to 0.23, metrics-exporter-prometheus to 0.15. [#52]
    • Document MSRV as 1.70 currently. [#52]

    Added

    • GenericMetricLayer::pair_from to initialize from a concrete struct. GenericMetricLayer::pair now requires that the handle type implements Default. [#49]
    • BaseMetricLayer that serves a more lightweight alternative to GenericMetricLayer. [#56]
    Open source →
  6. 0.6.1 23 Jan 2024
    Release notes
    • Disabled the "push-gateway" feature in metrics-exporter-prometheus by default, and added a way to enable it via
      the same name under axum_prometheus. This change ensures that this crate can still be built without openssl support, see here. [#44]
    • Update examples to metrics-exporter-prometheus to 0.13 and metrics to 0.22. [#43]
    Open source →
    Release notes
    • Disabled the "push-gateway" feature in metrics-exporter-prometheus by default, and added a way to enable it via the same name under axum_prometheus. This change ensures that this crate can still be built without openssl support, see here. [#44]
    • Update examples to metrics-exporter-prometheus to 0.13 and metrics to 0.22. [#43]
    Open source →
  7. 0.6.0 22 Jan 2024
    Release notes
    • Update metrics-exporter-prometheus to 0.13 and metrics to 0.22 #39
    Open source →
    Release notes
    • Update metrics-exporter-prometheus to 0.13 and metrics to 0.22. [#39]
    Open source →
  8. 0.5.0 27 Nov 2023
    Release notes

    Added

    • Support for response body size metric, which can be turned on via PrometheusMetricLayerBuilder::enable_response_body_size. [#33]
    • All metrics now are initialized via the metrics::describe_* functions by default, but can be turned off with PrometheusMetricLayerBuilder::no_initialize_metrics if you wish to do it manually. [#33]
    • Compatibility with http-body = "1.0" and axum = "0.7". [#36]

    Changed

    • The lower-level Lifecycle API has changed: separated the OnBodyChunk trait, which is ran when a response body chunk has been generated. [#33]
    Open source →
    Release notes

    Added

    • Support for response body size metric, which can be turned on via PrometheusMetricLayerBuilder::enable_response_body_size. [#33]
    • All metrics now are initialized via metrics::describe_* function by default, but can be turned off with PrometheusMetricLayerBuilder::no_initialize_metrics. [#33]
    • Compatibility with http-body = "1.0" andaxum = "0.7". [#36]

    Changed

    • The lower-level Lifecycle API has changed: separated the OnBodyChunk trait, which is ran when a response body chunk has been generated. [#\33]
    Open source →
  9. 0.4.0 24 Jul 2023
    Release notes

    Added

    • Support for different exporters than Prometheus. Developers now allowed to use their own exporter - as long as it's using the metrics.rs ecosystem. This is meant to be a non-breaking change - if you're using Prometheus, you shouldn't notice any changes in the public API. If you do however, please file an issue! #28
    • An example showcasing StatsD exporter #28
    • Simple snapshot tests #28
    • Utility functions to get metric names at runtime #28

    Fixed

    • Previous attempts to fix PrometheusMetricBuilder::with_prefix in 0.3.4 were not complete, this is now fully addressed. #28
    Open source →
    Release notes

    Added

    • Support for different exporters than Prometheus. Developers now allowed to use their own exporter - as long as it's using the metrics.rs ecosystem. This is meant to be a non-breaking change - if you're using Prometheus, you shouldn't notice any changes in the public API. If you do however, please file an issue! [#28]
    • An example showcasing StatsD exporter [#28]
    • Simple snapshot tests [#28]
    • Utility functions to get metric names at runtime [#28]

    Fixed

    • Previous attempts to fix PrometheusMetricBuilder::with_prefix in 0.3.4 were not complete, this is now fully addressed. [#28]
    Open source →
  10. 0.3.4 16 Jul 2023
    Release notes

    Fixed

    • PrometheusMetricBuilder::with_prefix is now properly setting the metric prefix, and the metric handle also takes that prefix into account. Previously the metric initialization incorrectly ignored the prefix, which caused the requests duration histogram to use quantile instead of le labels. [#26]. (Thanks @yanns!)
    Open source →
    Release notes

    Fixed

    • PrometheusMetricBuilder::with_prefix is now properly setting the metric prefix, and the metric handle also takes that prefix into account. Previously the metric initialization incorrectly ignored the prefix, which caused the requests duration histogram to use quantile instead of le labels.
    Open source →
  11. 0.3.3 02 May 2023
    Release notes
    • Update metrics-exporter-prometheus to 0.12 and metrics to 0.21.
    Open source →
  12. 0.3.2 25 Mar 2023
    Release notes

    Added

    • The status code of the response is now captured in the total requests counter metric.
    Open source →
  13. 0.3.1 16 Feb 2023
    Release notes

    Added

    • with_prefix to PrometheusMetricLayerBuilder, which can be used to rename the default prefix (axum) for all metrics. This is especially useful when working with cargo workspaces that has more than one axum_prometheus instance (since environment variables don't work there).

    0.3.0 - 2023-01-04

    Added

    • Routing patterns can be ignored, and grouped together when reporting to Prometheus.

    • Endpoint label behavior can be altered with the new EndpointLabel enum.

    • Added a new builder PrometheusMetricLayerBuilder to easily customize these.

      let (prometheus_layer, metric_handle) = PrometheusMetricLayerBuilder::new()
          // ignore reporting requests that match "/foo" or "/sensitive"
          .with_ignore_patterns(&["/foo", "/sensitive"])
          // if the any of the second argument matches, report them at the `/bar` endpoint
          .with_group_patterns_as("/bar", &["/foo/:bar", "/foo/:bar/:baz"])
          // use `axum::extract::MatchedPath`, and if that fails, use the exact requested URI
          .with_endpoint_label_type(EndpointLabel::MatchedPath)
          .with_default_metrics()
          .build_pair();
      
    • A builder-example and an endpoint-type-example.

    • The metric names can be changed by setting some environmental variables at compile time. It is best to set these in the config.toml (note this is not the same file as Cargo.toml):

      [env]
      AXUM_HTTP_REQUESTS_TOTAL = "my_app_requests_total"
      AXUM_HTTP_REQUESTS_DURATION_SECONDS = "my_app_requests_duration_seconds"
      AXUM_HTTP_REQUESTS_PENDING = "my_app_requests_pending"
      

    0.2.0 - 2022-10-25

    Added

    • Compatibility with axum-core = "0.3" and thus axum = "0.6".

    0.1.0

    First version.

    Open source →
  14. 0.3.0 04 Jan 2023

    Nothing published for this version

  15. 0.2.0 25 Nov 2022

    Nothing published for this version

  16. 0.1.0 20 Sep 2022

    Nothing published for this version

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive