Skip to content

Commit

Permalink
feat: allow using prometheus-client crate with PrometheusClientLayer (
Browse files Browse the repository at this point in the history
apache#3134)

* refactor prometheus layer

* add prometheus-client to deps

* chore: simplify imports

* refactor the metrics into a trait

* feat: add implementation with prometheus-client

* fix: allow using different trait

* cargo fmt

* refactor: add a seperate layer

* fix: docs

* fix typo

* fix: cargo fmt

* add a prefix

* use structed labels

* use labels in array

* remove the unused metrics

* rename stats to metrics

* record request duration in wrapper

* fix fmt
  • Loading branch information
flaneur2020 authored Sep 19, 2023
1 parent f846b6a commit 30de95e
Show file tree
Hide file tree
Showing 4 changed files with 714 additions and 1 deletion.
30 changes: 30 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ layers-all = [
layers-chaos = ["dep:rand"]
# Enable layers metrics support
layers-metrics = ["dep:metrics"]
# Enable layers prometheus support
# Enable layers prometheus support, with tikv/prometheus-rs crate
layers-prometheus = ["dep:prometheus"]
# Enable layers prometheus support, with prometheus-client crate
layers-prometheus-client = ["dep:prometheus-client"]
# Enable layers madsim support
layers-madsim = ["dep:madsim"]
# Enable layers minitrace support.
Expand Down Expand Up @@ -243,6 +245,7 @@ percent-encoding = "2"
persy = { version = "1.4.4", optional = true }
pin-project = "1"
prometheus = { version = "0.13", features = ["process"], optional = true }
prometheus-client = { version = "0.21.2", optional = true }
prost = { version = "0.11", optional = true }
quick-xml = { version = "0.29", features = ["serialize", "overlapped-lists"] }
rand = { version = "0.8", optional = true }
Expand Down
5 changes: 5 additions & 0 deletions core/src/layers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ mod prometheus;
#[cfg(feature = "layers-prometheus")]
pub use self::prometheus::PrometheusLayer;

#[cfg(feature = "layers-prometheus-client")]
mod prometheus_client;
#[cfg(feature = "layers-prometheus-client")]
pub use self::prometheus_client::PrometheusClientLayer;

mod retry;
pub use self::retry::RetryInterceptor;
pub use self::retry::RetryLayer;
Expand Down
Loading

0 comments on commit 30de95e

Please sign in to comment.