Skip to content

Commit

Permalink
Merge pull request #12 from Ptrskay3/release/0.3.1
Browse files Browse the repository at this point in the history
release/0.3.1
  • Loading branch information
Ptrskay3 authored Feb 16, 2023
2 parents 54323b9 + ae18538 commit 3c65efa
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.

-

# [0.3.1] - 2023-02-16

### 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
Expand Down Expand Up @@ -46,6 +53,7 @@ All notable changes to this project will be documented in this file.

First version.

[unreleased]: https://github.com/Ptrskay3/axum-prometheus/compare/master...release/0.3
[unreleased]: https://github.com/Ptrskay3/axum-prometheus/compare/master...release/0.3.1
[0.2.0]: https://github.com/Ptrskay3/axum-prometheus/compare/9fb600d7d9ac2e6d38e6399119fc7ba7f25d5fe0...756dc67bf2baae2de406e012bdaa2334ce0fcdcb
[0.3.0]: https://github.com/Ptrskay3/axum-prometheus/compare/axum-0.6...release/0.3
[0.3.1]: https://github.com/Ptrskay3/axum-prometheus/compare/master...release/0.3.1
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "axum-prometheus"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
homepage = "https://github.com/Ptrskay3/axum-prometheus"
license = "MIT"
Expand All @@ -23,7 +23,7 @@ tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros"] }
tower-http = "0.3.4"
bytes = "1.2.1"
futures-core = "0.3.24"
matchit = "0.6"
matchit = "0.7"
once_cell = "1.17.0"

[dev-dependencies]
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ AXUM_HTTP_REQUESTS_DURATION_SECONDS = "my_app_requests_duration_seconds"
AXUM_HTTP_REQUESTS_PENDING = "my_app_requests_pending"
```

..or optionally use [`PrometheusMetricLayerBuilder::with_prefix`] function.

### Compatibility

| Axum Version | Crate Version |
Expand All @@ -58,7 +60,7 @@ Add `axum-prometheus` to your `Cargo.toml`.

```toml
[dependencies]
axum-prometheus = "0.3.0"
axum-prometheus = "0.3.1"
```

Then you instantiate the prometheus middleware:
Expand Down
1 change: 1 addition & 0 deletions examples/builder-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async fn main() {
.init();

let (prometheus_layer, metric_handle) = PrometheusMetricLayerBuilder::new()
.with_prefix("builder-example")
// ignore reporting requests that match "/metrics"
.with_ignore_pattern("/metrics")
// if the any of the second argument matches, report them at the `/foo` endpoint
Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
//! AXUM_HTTP_REQUESTS_PENDING = "my_app_requests_pending"
//! ```
//!
//! ..or optionally use [`PrometheusMetricLayerBuilder::with_prefix`] function.
//!
//! ## Usage
//!
//! For more elaborate use-cases, see the builder-example that leverages [`PrometheusMetricLayerBuilder`].
//!
//! Add `axum-prometheus` to your `Cargo.toml`.
//! ```not_rust
//! [dependencies]
//! axum-prometheus = "0.3.0"
//! axum-prometheus = "0.3.1"
//! ```
//!
//! Then you instantiate the prometheus middleware:
Expand Down Expand Up @@ -115,8 +117,11 @@ pub const AXUM_HTTP_REQUESTS_TOTAL: &str = match option_env!("AXUM_HTTP_REQUESTS
None => "axum_http_requests_total",
};

#[doc(hidden)]
pub static PREFIXED_HTTP_REQUESTS_TOTAL: OnceCell<String> = OnceCell::new();
#[doc(hidden)]
pub static PREFIXED_HTTP_REQUESTS_DURATION_SECONDS: OnceCell<String> = OnceCell::new();
#[doc(hidden)]
pub static PREFIXED_HTTP_REQUESTS_PENDING: OnceCell<String> = OnceCell::new();

use std::borrow::Cow;
Expand Down

0 comments on commit 3c65efa

Please sign in to comment.