From f0fdec1eb01804aea2bf9cd64e0a1fc4e55e206b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 10 Apr 2024 10:02:29 -0700 Subject: [PATCH] fixup and fully migrate to metrics 0.22 Commit 12fe5e3b61552c94f54c129928bb8698890a49fc updated the metrics related crates, but not in every one of our crates, which meant that we were running with a mixture of 0.20 and 0.22. The result of this was that the memory related metrics were no long visible to the published prometheus data because it was only looking at the other version of the metrics crate! This commit switches over to using a workspace dep for metrics so that we update all related crates together. --- Cargo.lock | 62 +++++----------------------- Cargo.toml | 1 + crates/config/Cargo.toml | 2 +- crates/config/src/lib.rs | 6 +-- crates/kumo-server-common/Cargo.toml | 2 +- crates/kumo-server-memory/Cargo.toml | 2 +- crates/kumo-server-memory/src/lib.rs | 6 +-- crates/kumod/Cargo.toml | 2 +- 8 files changed, 21 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2b75b4b..5ae6f506 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.11" @@ -930,7 +919,7 @@ version = "0.1.0" dependencies = [ "anyhow", "lazy_static", - "metrics 0.20.1", + "metrics", "mlua", "serde", "serde_json", @@ -1952,7 +1941,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.11", + "ahash", ] [[package]] @@ -2679,7 +2668,7 @@ dependencies = [ "kumo-server-runtime", "libc", "mac_address", - "metrics 0.22.3", + "metrics", "metrics-prometheus", "metrics-tracing-context", "mlua", @@ -2734,7 +2723,7 @@ dependencies = [ "cgroups-rs", "humansize", "lazy_static", - "metrics 0.20.1", + "metrics", "nix 0.28.0", "tikv-jemalloc-sys", "tikv-jemallocator", @@ -2794,7 +2783,7 @@ dependencies = [ "maplit", "memchr", "message", - "metrics 0.22.3", + "metrics", "minijinja", "minijinja-contrib", "mlua", @@ -3227,36 +3216,14 @@ dependencies = [ "tokio", ] -[[package]] -name = "metrics" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b9b8653cec6897f73b519a43fba5ee3d50f62fe9af80b428accdcc093b4a849" -dependencies = [ - "ahash 0.7.8", - "metrics-macros", - "portable-atomic 0.3.20", -] - [[package]] name = "metrics" version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2be3cbd384d4e955b231c895ce10685e3d8260c5ccffae898c96c723b0772835" dependencies = [ - "ahash 0.8.11", - "portable-atomic 1.6.0", -] - -[[package]] -name = "metrics-macros" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "731f8ecebd9f3a4aa847dfe75455e4757a45da40a7793d2f0b1f9b6ed18b23f3" -dependencies = [ - "proc-macro2 1.0.79", - "quote 1.0.35", - "syn 1.0.109", + "ahash", + "portable-atomic", ] [[package]] @@ -3266,7 +3233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3e1316f9ef05b91f4d0e0a0da5b620ba919d336280b83b36be096b86c030fdd" dependencies = [ "arc-swap", - "metrics 0.22.3", + "metrics", "metrics-util", "once_cell", "prometheus", @@ -3284,7 +3251,7 @@ dependencies = [ "indexmap 2.2.6", "itoa", "lockfree-object-pool", - "metrics 0.22.3", + "metrics", "metrics-util", "once_cell", "tracing", @@ -3303,7 +3270,7 @@ dependencies = [ "crossbeam-utils", "hashbrown 0.14.3", "indexmap 2.2.6", - "metrics 0.22.3", + "metrics", "num_cpus", "ordered-float 4.2.0", "quanta", @@ -4221,15 +4188,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "portable-atomic" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30165d31df606f5726b090ec7592c308a0eaf61721ff64c9a3018e344a8753e" -dependencies = [ - "portable-atomic 1.6.0", -] - [[package]] name = "portable-atomic" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index 52205789..6175e126 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ data-encoding = "2.4" ed25519-dalek = "2.0" futures = "0.3.28" libunbound = {git="https://github.com/KumoCorp/libunbound-rs.git", rev="1f629e81919d8aae7e95fff82dc1390912b4ba53"} +metrics = "0.22" mlua = "0.8" once_cell = "1.17" openssl = { version="=0.10.60" } # pinned; see patch below diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index c8f31cc7..766db44b 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0" lazy_static= "1.4" -metrics = "0.20" +metrics = {workspace=true} mlua = {workspace=true, features=["vendored", "lua54", "async", "send", "serialize"]} serde = "1.0" serde_json = "1.0" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 6acd0cb9..12db7f87 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -17,18 +17,18 @@ lazy_static::lazy_static! { "lua_load_count", "how many times the policy lua script has been \ loaded into a new context"); - metrics::register_counter!("lua_load_count") + metrics::counter!("lua_load_count") }; static ref LUA_COUNT: metrics::Gauge = { metrics::describe_gauge!( "lua_count", "the number of lua contexts currently alive"); - metrics::register_gauge!("lua_count") + metrics::gauge!("lua_count") }; static ref LUA_SPARE_COUNT: metrics::Gauge = { metrics::describe_gauge!( "lua_spare_count", "the number of lua contexts available for reuse in the pool"); - metrics::register_gauge!("lua_spare_count") + metrics::gauge!("lua_spare_count") }; static ref CALLBACK_ALLOWS_MULTIPLE: Mutex> = Mutex::new(HashSet::new()); } diff --git a/crates/kumo-server-common/Cargo.toml b/crates/kumo-server-common/Cargo.toml index 0420f5eb..dce2822c 100644 --- a/crates/kumo-server-common/Cargo.toml +++ b/crates/kumo-server-common/Cargo.toml @@ -26,7 +26,7 @@ kumo-server-memory = {path="../kumo-server-memory"} kumo-server-runtime = {path="../kumo-server-runtime"} libc = "0.2.139" mac_address = "1.1" -metrics = "0.22" +metrics = {workspace=true} metrics-prometheus = "0.6" metrics-tracing-context = "0.15" mlua = {workspace=true, features=["vendored", "lua54", "async", "send", "serialize"]} diff --git a/crates/kumo-server-memory/Cargo.toml b/crates/kumo-server-memory/Cargo.toml index 3daba9a4..992d3a75 100644 --- a/crates/kumo-server-memory/Cargo.toml +++ b/crates/kumo-server-memory/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0" humansize = "2.1" # for printing lazy_static = "1.4" -metrics = "0.20" +metrics = {workspace=true} nix = {version="0.28", features=["resource", "feature"]} tikv-jemallocator = "0.5" tikv-jemalloc-sys = {version="0.5", features=["profiling", "unprefixed_malloc_on_supported_platforms"]} diff --git a/crates/kumo-server-memory/src/lib.rs b/crates/kumo-server-memory/src/lib.rs index 7daffaca..db022de0 100644 --- a/crates/kumo-server-memory/src/lib.rs +++ b/crates/kumo-server-memory/src/lib.rs @@ -27,17 +27,17 @@ lazy_static::lazy_static! { metrics::describe_counter!( "memory_over_limit_count", "how many times the soft memory limit was exceeded"); - metrics::register_counter!("memory_over_limit_count") + metrics::counter!("memory_over_limit_count") }; static ref MEM_USAGE: metrics::Gauge = { metrics::describe_gauge!( "memory_usage", "number of bytes of used memory"); - metrics::register_gauge!("memory_usage") + metrics::gauge!("memory_usage") }; static ref MEM_LIMIT: metrics::Gauge = { metrics::describe_gauge!( "memory_limit", "soft memory limit measured in bytes"); - metrics::register_gauge!("memory_limit") + metrics::gauge!("memory_limit") }; static ref SUBSCRIBER: Mutex>> = Mutex::new(None); } diff --git a/crates/kumod/Cargo.toml b/crates/kumod/Cargo.toml index 6d68c3a2..070744f7 100644 --- a/crates/kumod/Cargo.toml +++ b/crates/kumod/Cargo.toml @@ -39,7 +39,7 @@ maildir = {path="../maildir"} mailparsing = {path="../mailparsing"} memchr = "2.5" message = {path="../message"} -metrics = "0.22" +metrics = {workspace=true} minijinja-contrib = {version="1.0.9",features=["datetime", "timezone"]} minijinja = {version="1.0.9",features=["loader", "builtins", "json"]} mlua = {workspace=true, features=["vendored", "lua54", "async", "send", "serialize"]}