From c992dc4218fe1b8bfa81747be20ffaf75788bc8a Mon Sep 17 00:00:00 2001 From: Lucas Kent Date: Fri, 9 Feb 2024 23:21:55 +1100 Subject: [PATCH] Update metrics crate (#1462) --- Cargo.lock | 220 +++++++++--------- Cargo.toml | 2 +- shotover/Cargo.toml | 4 +- shotover/benches/benches/main.rs | 2 +- shotover/src/codec/cassandra.rs | 8 +- shotover/src/codec/mod.rs | 6 +- shotover/src/runner.rs | 2 +- shotover/src/server.rs | 5 +- .../transforms/cassandra/sink_cluster/mod.rs | 4 +- .../cassandra/sink_cluster/node_pool.rs | 4 +- .../src/transforms/cassandra/sink_single.rs | 4 +- shotover/src/transforms/chain.rs | 24 +- shotover/src/transforms/query_counter.rs | 14 +- shotover/src/transforms/redis/cache.rs | 10 +- shotover/src/transforms/redis/sink_cluster.rs | 6 +- shotover/src/transforms/redis/sink_single.rs | 4 +- shotover/src/transforms/tee.rs | 5 +- 17 files changed, 168 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd8a1f753..a9e8da1f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -404,9 +404,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ee2d09cce0ef3ae526679b522835d63e75fb427aca5413cd371e490d52dcc6" +checksum = "426a5bc369ca7c8d3686439e46edc727f397a47ab3696b13f3ae8c81b3b36132" dependencies = [ "futures-util", "pin-project-lite", @@ -415,9 +415,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.4" +version = "0.60.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dab56aea3cd9e1101a0a999447fb346afb680ab1406cebc44b32346e25b4117d" +checksum = "85d6a0619f7b67183067fa3b558f94f90753da2df8c04aeb7336d673f804b0b8" dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", @@ -435,18 +435,18 @@ dependencies = [ [[package]] name = "aws-smithy-json" -version = "0.60.4" +version = "0.60.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3898ca6518f9215f62678870064398f00031912390efd03f1f6ef56d83aa8e" +checksum = "a1c1b5186b6f5c579bf0de1bcca9dd3d946d6d51361ea1d18131f6a0b64e13ae" dependencies = [ "aws-smithy-types", ] [[package]] name = "aws-smithy-query" -version = "0.60.4" +version = "0.60.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda4b1dfc9810e35fba8a620e900522cd1bd4f9578c446e82f49d1ce41d2e9f9" +checksum = "1c0a2ce65882e788d2cf83ff28b9b16918de0460c47bf66c5da4f6c17b4c9694" dependencies = [ "aws-smithy-types", "urlencoding", @@ -454,9 +454,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fafdab38f40ad7816e7da5dec279400dd505160780083759f01441af1bbb10ea" +checksum = "b4cb6b3afa5fc9825a75675975dcc3e21764b5476bc91dbc63df4ea3d30a576e" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -479,9 +479,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c18276dd28852f34b3bf501f4f3719781f4999a51c7bff1a5c6dc8c4529adc29" +checksum = "23165433e80c04e8c09cee66d171292ae7234bae05fa9d5636e33095eae416b2" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -495,9 +495,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb3e134004170d3303718baa2a4eb4ca64ee0a1c0a7041dca31b38be0fb414f3" +checksum = "c94a5bec34850b92c9a054dad57b95c1d47f25125f55973e19f6ad788f0381ff" dependencies = [ "base64-simd", "bytes", @@ -518,9 +518,9 @@ dependencies = [ [[package]] name = "aws-smithy-xml" -version = "0.60.4" +version = "0.60.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8604a11b25e9ecaf32f9aa56b9fe253c5e2f606a3477f0071e96d3155a5ed218" +checksum = "d16f94c9673412b7a72e3c3efec8de89081c320bf59ea12eed34c417a62ad600" dependencies = [ "xmlparser", ] @@ -700,9 +700,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "ea31d69bda4949c1c1562c1e6f042a1caefac98cdc8a298260a2ff41c1e2d42b" dependencies = [ "bytemuck_derive", ] @@ -991,9 +991,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", "clap_derive", @@ -1001,21 +1001,21 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.0", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -1025,15 +1025,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "clipboard-win" -version = "5.0.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c57002a5d9be777c1ef967e33674dac9ebd310d8893e4e3437b14d5f0f6372cc" +checksum = "3ec832972fefb8cf9313b45a0d1945e29c9c251f1d4c6eafc5fe2124c02d2e81" dependencies = [ "error-code", ] @@ -1187,9 +1187,9 @@ checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff" [[package]] name = "crc32c" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f48d60e5b4d2c53d5c2b1d8a58c849a70ae5e5509b08a48d047e3b65714a74" +checksum = "89254598aa9b9fa608de44b3ae54c810f0f06d755e24c50177f1f8f31ff50ce2" dependencies = [ "rustc_version", ] @@ -1345,9 +1345,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.1" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" dependencies = [ "cfg-if", "cpufeatures", @@ -1416,7 +1416,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -1430,7 +1430,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 2.0.48", ] @@ -1643,9 +1643,9 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", @@ -1773,9 +1773,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" [[package]] name = "flate2" @@ -2035,7 +2035,7 @@ dependencies = [ "no-std-compat", "nonzero_ext", "parking_lot", - "quanta", + "quanta 0.11.1", "rand 0.8.5", "smallvec", ] @@ -2131,9 +2131,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -2233,7 +2233,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tower-service", "tracing", @@ -2413,18 +2413,18 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -2577,56 +2577,40 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "metrics" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fde3af1a009ed76a778cb84fdef9e7dbbdf5775ae3e4cc1f434a6a307f6f76c5" +checksum = "77b9e10a211c839210fd7f99954bda26e5f8e26ec686ad68da6a32df7c80e782" dependencies = [ "ahash", - "metrics-macros", "portable-atomic", ] [[package]] name = "metrics-exporter-prometheus" -version = "0.12.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d4fa7ce7c4862db464a37b0b31d89bca874562f034bd7993895572783d02950" +checksum = "83a4c4718a371ddfb7806378f23617876eea8b82e5ff1324516bcd283249d9ea" dependencies = [ "base64", - "hyper", "indexmap 1.9.3", - "ipnet", "metrics", "metrics-util", - "quanta", + "quanta 0.12.2", "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "metrics-macros" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", ] [[package]] name = "metrics-util" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de2ed6e491ed114b40b732e4d1659a9d53992ebd87490c44a6ffe23739d973e" +checksum = "2670b8badcc285d486261e2e9f1615b506baff91427b61bd336a472b65bbf5ed" dependencies = [ "crossbeam-epoch", "crossbeam-utils", "hashbrown 0.13.1", "metrics", "num_cpus", - "quanta", + "quanta 0.12.2", "sketches-ddsketch", ] @@ -2787,9 +2771,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", "serde", @@ -2803,19 +2787,18 @@ checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg", "num-integer", @@ -2837,9 +2820,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", @@ -3321,7 +3304,22 @@ dependencies = [ "libc", "mach2", "once_cell", - "raw-cpuid", + "raw-cpuid 10.7.0", + "wasi 0.11.0+wasi-snapshot-preview1", + "web-sys", + "winapi", +] + +[[package]] +name = "quanta" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca0b7bac0b97248c40bb77288fc52029cf1459c0461ea1b05ee32ccf011de2c" +dependencies = [ + "crossbeam-utils", + "libc", + "once_cell", + "raw-cpuid 11.0.1", "wasi 0.11.0+wasi-snapshot-preview1", "web-sys", "winapi", @@ -3447,6 +3445,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "raw-cpuid" +version = "11.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" +dependencies = [ + "bitflags 2.4.2", +] + [[package]] name = "rayon" version = "1.8.1" @@ -4552,6 +4559,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "strum" version = "0.23.0" @@ -4660,13 +4673,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", "windows-sys 0.52.0", ] @@ -5177,9 +5189,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -5317,9 +5329,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -5327,9 +5339,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -5342,9 +5354,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -5354,9 +5366,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5364,9 +5376,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -5377,15 +5389,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -5592,9 +5604,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.37" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index a990d586f..963a48fb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,5 +64,5 @@ typetag = "0.2.5" aws-throwaway = { version = "0.6.0", default-features = false } tokio-bin-process = "0.4.0" ordered-float = { version = "4.0.0", features = ["serde"] } -hyper = { version = "0.14.14", features = ["server"] } +hyper = { version = "0.14.14", features = ["server", "tcp", "http1"] } shell-quote = { default-features = false, version = "0.5.0" } diff --git a/shotover/Cargo.toml b/shotover/Cargo.toml index 465b6cecc..d0bef96dc 100644 --- a/shotover/Cargo.toml +++ b/shotover/Cargo.toml @@ -91,8 +91,8 @@ httparse = { version = "1.8.0", optional = true } http = { version = "1.0.0", optional = true } #Observability -metrics = "0.21.0" -metrics-exporter-prometheus = "0.12.0" +metrics = "0.22.0" +metrics-exporter-prometheus = { version = "0.13.0", default-features = false } tracing.workspace = true tracing-subscriber.workspace = true tracing-appender.workspace = true diff --git a/shotover/benches/benches/main.rs b/shotover/benches/benches/main.rs index 297e22588..4481b9e22 100644 --- a/shotover/benches/benches/main.rs +++ b/shotover/benches/benches/main.rs @@ -9,7 +9,7 @@ fn init() { std::env::set_var("RUST_LIB_BACKTRACE", "0"); let recorder = PrometheusBuilder::new().build_recorder(); - metrics::set_boxed_recorder(Box::new(recorder)).ok(); + metrics::set_global_recorder(recorder).ok(); } criterion_main!( diff --git a/shotover/src/codec/cassandra.rs b/shotover/src/codec/cassandra.rs index 87d8be543..ce4d839dc 100644 --- a/shotover/src/codec/cassandra.rs +++ b/shotover/src/codec/cassandra.rs @@ -13,7 +13,7 @@ use cassandra_protocol::frame::{Flags, Opcode, Version, PAYLOAD_SIZE_LIMIT}; use cql3_parser::cassandra_statement::CassandraStatement; use cql3_parser::common::Identifier; use lz4_flex::{block::get_maximum_output_size, compress_into, decompress}; -use metrics::{register_counter, Counter, Histogram}; +use metrics::{counter, Counter, Histogram}; use std::collections::HashMap; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; @@ -154,9 +154,9 @@ pub struct VersionCounter { impl VersionCounter { fn new() -> Self { Self { - v3: register_counter!("shotover_client_protocol_version_count", "version" => "v3"), - v4: register_counter!("shotover_client_protocol_version_count", "version" => "v4"), - v5: register_counter!("shotover_client_protocol_version_count", "version" => "v5"), + v3: counter!("shotover_client_protocol_version_count", "version" => "v3"), + v4: counter!("shotover_client_protocol_version_count", "version" => "v4"), + v5: counter!("shotover_client_protocol_version_count", "version" => "v5"), } } diff --git a/shotover/src/codec/mod.rs b/shotover/src/codec/mod.rs index 76f2a89a7..8280c98a3 100644 --- a/shotover/src/codec/mod.rs +++ b/shotover/src/codec/mod.rs @@ -6,7 +6,7 @@ use cassandra_protocol::compression::Compression; use core::fmt; #[cfg(feature = "kafka")] use kafka::RequestHeader; -use metrics::{register_histogram, Histogram}; +use metrics::{histogram, Histogram}; use tokio_util::codec::{Decoder, Encoder}; #[cfg(feature = "cassandra")] @@ -36,10 +36,10 @@ impl fmt::Display for Direction { pub fn message_latency(direction: Direction, destination_name: String) -> Histogram { match direction { Direction::Source => { - register_histogram!("shotover_sink_to_source_latency_seconds", "source" => destination_name) + histogram!("shotover_sink_to_source_latency_seconds", "source" => destination_name) } Direction::Sink => { - register_histogram!("shotover_source_to_sink_latency_seconds", "sink" => destination_name) + histogram!("shotover_source_to_sink_latency_seconds", "sink" => destination_name) } } } diff --git a/shotover/src/runner.rs b/shotover/src/runner.rs index e8018176b..7a351011e 100644 --- a/shotover/src/runner.rs +++ b/shotover/src/runner.rs @@ -129,7 +129,7 @@ impl Shotover { .unwrap() .build_recorder(); let handle = recorder.handle(); - metrics::set_boxed_recorder(Box::new(recorder))?; + metrics::set_global_recorder(recorder)?; let socket: SocketAddr = config.observability_interface.parse()?; let exporter = LogFilterHttpExporter::new(handle, socket, tracing.handle.clone()); diff --git a/shotover/src/server.rs b/shotover/src/server.rs index d5a63a007..d943575fd 100644 --- a/shotover/src/server.rs +++ b/shotover/src/server.rs @@ -9,7 +9,7 @@ use anyhow::{anyhow, Context, Result}; use bytes::BytesMut; use futures::future::join_all; use futures::{SinkExt, StreamExt}; -use metrics::{register_gauge, Gauge}; +use metrics::{gauge, Gauge}; use std::io::ErrorKind; use std::net::SocketAddr; use std::sync::Arc; @@ -88,7 +88,8 @@ impl TcpCodecListener { timeout: Option, transport: Transport, ) -> Result> { - let available_connections_gauge = register_gauge!("shotover_available_connections_count", "source" => source_name.clone()); + let available_connections_gauge = + gauge!("shotover_available_connections_count", "source" => source_name.clone()); available_connections_gauge.set(limit_connections.available_permits() as f64); let chain_builder = chain_config diff --git a/shotover/src/transforms/cassandra/sink_cluster/mod.rs b/shotover/src/transforms/cassandra/sink_cluster/mod.rs index 37aed7f36..6349102bb 100644 --- a/shotover/src/transforms/cassandra/sink_cluster/mod.rs +++ b/shotover/src/transforms/cassandra/sink_cluster/mod.rs @@ -17,7 +17,7 @@ use cql3_parser::cassandra_statement::CassandraStatement; use cql3_parser::common::IdentifierRef; use futures::stream::FuturesOrdered; use futures::StreamExt; -use metrics::{register_counter, Counter}; +use metrics::{counter, Counter}; use node::{CassandraNode, ConnectionFactory}; use node_pool::{GetReplicaErr, KeyspaceMetadata, NodePool}; use rand::prelude::*; @@ -116,7 +116,7 @@ impl CassandraSinkClusterBuilder { connect_timeout_ms: u64, timeout: Option, ) -> Self { - let failed_requests = register_counter!("shotover_failed_requests_count", "chain" => chain_name.clone(), "transform" => "CassandraSinkCluster"); + let failed_requests = counter!("shotover_failed_requests_count", "chain" => chain_name.clone(), "transform" => "CassandraSinkCluster"); let receive_timeout = timeout.map(Duration::from_secs); let connect_timeout = Duration::from_millis(connect_timeout_ms); diff --git a/shotover/src/transforms/cassandra/sink_cluster/node_pool.rs b/shotover/src/transforms/cassandra/sink_cluster/node_pool.rs index 008b87127..b4cce894b 100644 --- a/shotover/src/transforms/cassandra/sink_cluster/node_pool.rs +++ b/shotover/src/transforms/cassandra/sink_cluster/node_pool.rs @@ -6,7 +6,7 @@ use crate::transforms::cassandra::connection::CassandraConnection; use anyhow::{anyhow, Context, Error, Result}; use cassandra_protocol::frame::message_execute::BodyReqExecuteOwned; use cassandra_protocol::types::CBytesShort; -use metrics::{register_counter, Counter}; +use metrics::{counter, Counter}; use rand::prelude::*; use std::sync::Arc; use std::{collections::HashMap, net::SocketAddr}; @@ -52,7 +52,7 @@ impl NodePoolBuilder { pub fn new(chain_name: String) -> Self { Self { prepared_metadata: Arc::new(RwLock::new(HashMap::new())), - out_of_rack_requests: register_counter!("shotover_out_of_rack_requests_count", "chain" => chain_name, "transform" => "CassandraSinkCluster"), + out_of_rack_requests: counter!("shotover_out_of_rack_requests_count", "chain" => chain_name, "transform" => "CassandraSinkCluster"), } } diff --git a/shotover/src/transforms/cassandra/sink_single.rs b/shotover/src/transforms/cassandra/sink_single.rs index 488595f13..eba0f1fc9 100644 --- a/shotover/src/transforms/cassandra/sink_single.rs +++ b/shotover/src/transforms/cassandra/sink_single.rs @@ -9,7 +9,7 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; use cassandra_protocol::frame::Version; use futures::stream::FuturesOrdered; -use metrics::{register_counter, Counter}; +use metrics::{counter, Counter}; use serde::{Deserialize, Serialize}; use std::time::Duration; use tokio::sync::{mpsc, oneshot}; @@ -60,7 +60,7 @@ impl CassandraSinkSingleBuilder { connect_timeout_ms: u64, timeout: Option, ) -> CassandraSinkSingleBuilder { - let failed_requests = register_counter!("shotover_failed_requests_count", "chain" => chain_name, "transform" => "CassandraSinkSingle"); + let failed_requests = counter!("shotover_failed_requests_count", "chain" => chain_name, "transform" => "CassandraSinkSingle"); let receive_timeout = timeout.map(Duration::from_secs); let codec_builder = CassandraCodecBuilder::new(Direction::Sink, "CassandraSinkSingle".to_owned()); diff --git a/shotover/src/transforms/chain.rs b/shotover/src/transforms/chain.rs index c61110e04..dd5b798e0 100644 --- a/shotover/src/transforms/chain.rs +++ b/shotover/src/transforms/chain.rs @@ -3,7 +3,7 @@ use crate::transforms::{Transform, TransformBuilder, Wrapper}; use anyhow::{anyhow, Result}; use derivative::Derivative; use futures::TryFutureExt; -use metrics::{histogram, register_counter, register_histogram, Counter, Histogram}; +use metrics::{counter, histogram, Counter, Histogram}; use std::net::SocketAddr; use tokio::sync::{mpsc, oneshot}; use tokio::time::{Duration, Instant}; @@ -168,7 +168,7 @@ impl TransformChain { self.chain_failures.increment(1); } - histogram!("shotover_chain_latency_seconds", start.elapsed(), "chain" => self.name, "client_details" => client_details); + histogram!("shotover_chain_latency_seconds", "chain" => self.name, "client_details" => client_details).record(start.elapsed()); result } @@ -184,7 +184,7 @@ impl TransformChain { self.chain_failures.increment(1); } - histogram!("shotover_chain_latency_seconds", start.elapsed(), "chain" => self.name, "client_details" => client_details); + histogram!("shotover_chain_latency_seconds", "chain" => self.name, "client_details" => client_details).record(start.elapsed()); result } } @@ -264,20 +264,20 @@ impl TransformChainBuilder { pub fn new(chain: Vec>, name: &'static str) -> Self { let chain = chain.into_iter().map(|builder| TransformBuilderAndMetrics { - transform_total: register_counter!("shotover_transform_total_count", "transform" => builder.get_name()), - transform_failures: register_counter!("shotover_transform_failures_count", "transform" => builder.get_name()), - transform_latency: register_histogram!("shotover_transform_latency_seconds", "transform" => builder.get_name()), - transform_pushed_total: register_counter!("shotover_transform_pushed_total_count", "transform" => builder.get_name()), - transform_pushed_failures: register_counter!("shotover_transform_pushed_failures_count", "transform" => builder.get_name()), - transform_pushed_latency: register_histogram!("shotover_transform_pushed_latency_seconds", "transform" => builder.get_name()), + transform_total: counter!("shotover_transform_total_count", "transform" => builder.get_name()), + transform_failures: counter!("shotover_transform_failures_count", "transform" => builder.get_name()), + transform_latency: histogram!("shotover_transform_latency_seconds", "transform" => builder.get_name()), + transform_pushed_total: counter!("shotover_transform_pushed_total_count", "transform" => builder.get_name()), + transform_pushed_failures: counter!("shotover_transform_pushed_failures_count", "transform" => builder.get_name()), + transform_pushed_latency: histogram!("shotover_transform_pushed_latency_seconds", "transform" => builder.get_name()), builder, } ).collect(); let chain_batch_size = - register_histogram!("shotover_chain_messages_per_batch_count", "chain" => name); - let chain_total = register_counter!("shotover_chain_total_count", "chain" => name); - let chain_failures = register_counter!("shotover_chain_failures_count", "chain" => name); + histogram!("shotover_chain_messages_per_batch_count", "chain" => name); + let chain_total = counter!("shotover_chain_total_count", "chain" => name); + let chain_failures = counter!("shotover_chain_failures_count", "chain" => name); // Cant register shotover_chain_latency_seconds because a unique one is created for each client ip address TransformChainBuilder { diff --git a/shotover/src/transforms/query_counter.rs b/shotover/src/transforms/query_counter.rs index fe9685db5..f71012fce 100644 --- a/shotover/src/transforms/query_counter.rs +++ b/shotover/src/transforms/query_counter.rs @@ -4,7 +4,7 @@ use crate::transforms::TransformConfig; use crate::transforms::{Transform, TransformBuilder, Wrapper}; use anyhow::Result; use async_trait::async_trait; -use metrics::{counter, register_counter}; +use metrics::counter; use serde::Deserialize; use serde::Serialize; @@ -21,7 +21,7 @@ pub struct QueryCounterConfig { impl QueryCounter { pub fn new(counter_name: String) -> Self { - register_counter!("shotover_query_count", "name" => counter_name.clone()); + counter!("shotover_query_count", "name" => counter_name.clone()); QueryCounter { counter_name } } @@ -49,20 +49,20 @@ impl Transform for QueryCounter { #[cfg(feature = "cassandra")] Some(Frame::Cassandra(frame)) => { for statement in frame.operation.queries() { - counter!("shotover_query_count", 1, "name" => self.counter_name.clone(), "query" => statement.short_name(), "type" => "cassandra"); + counter!("shotover_query_count", "name" => self.counter_name.clone(), "query" => statement.short_name(), "type" => "cassandra").increment(1); } } #[cfg(feature = "redis")] Some(Frame::Redis(frame)) => { if let Some(query_type) = crate::frame::redis::redis_query_name(frame) { - counter!("shotover_query_count", 1, "name" => self.counter_name.clone(), "query" => query_type, "type" => "redis"); + counter!("shotover_query_count", "name" => self.counter_name.clone(), "query" => query_type, "type" => "redis").increment(1); } else { - counter!("shotover_query_count", 1, "name" => self.counter_name.clone(), "query" => "unknown", "type" => "redis"); + counter!("shotover_query_count", "name" => self.counter_name.clone(), "query" => "unknown", "type" => "redis").increment(1); } } #[cfg(feature = "kafka")] Some(Frame::Kafka(_)) => { - counter!("shotover_query_count", 1, "name" => self.counter_name.clone(), "query" => "unknown", "type" => "kafka"); + counter!("shotover_query_count", "name" => self.counter_name.clone(), "query" => "unknown", "type" => "kafka").increment(1); } Some(Frame::Dummy) => { // Dummy does not count as a message @@ -72,7 +72,7 @@ impl Transform for QueryCounter { todo!(); } None => { - counter!("shotover_query_count", 1, "name" => self.counter_name.clone(), "query" => "unknown", "type" => "none") + counter!("shotover_query_count", "name" => self.counter_name.clone(), "query" => "unknown", "type" => "none").increment(1) } } } diff --git a/shotover/src/transforms/redis/cache.rs b/shotover/src/transforms/redis/cache.rs index be48c7461..ab629874e 100644 --- a/shotover/src/transforms/redis/cache.rs +++ b/shotover/src/transforms/redis/cache.rs @@ -11,7 +11,7 @@ use cql3_parser::cassandra_statement::CassandraStatement; use cql3_parser::common::{FQName, Identifier, Operand, RelationElement, RelationOperator}; use cql3_parser::select::Select; use itertools::Itertools; -use metrics::{register_counter, Counter}; +use metrics::{counter, Counter}; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap}; use std::net::SocketAddr; @@ -86,7 +86,7 @@ const NAME: &str = "RedisCache"; #[async_trait(?Send)] impl TransformConfig for RedisConfig { async fn get_builder(&self, _chain_name: String) -> Result> { - let missed_requests = register_counter!("shotover_cache_miss_count"); + let missed_requests = counter!("shotover_cache_miss_count"); let caching_schema: HashMap = self .caching_schema @@ -611,7 +611,7 @@ mod test { use crate::transforms::TransformBuilder; use bytes::Bytes; use cql3_parser::common::Identifier; - use metrics::register_counter; + use metrics::counter; use std::collections::HashMap; #[test] @@ -811,7 +811,7 @@ mod test { let transform = SimpleRedisCacheBuilder { cache_chain: TransformChainBuilder::new(vec![], "test-chain"), caching_schema: HashMap::new(), - missed_requests: register_counter!("cache_miss"), + missed_requests: counter!("cache_miss"), }; assert_eq!( @@ -838,7 +838,7 @@ mod test { let transform = SimpleRedisCacheBuilder { cache_chain, caching_schema: HashMap::new(), - missed_requests: register_counter!("cache_miss"), + missed_requests: counter!("cache_miss"), }; assert_eq!(transform.validate(), Vec::::new()); diff --git a/shotover/src/transforms/redis/sink_cluster.rs b/shotover/src/transforms/redis/sink_cluster.rs index ae330d517..e6ec633a4 100644 --- a/shotover/src/transforms/redis/sink_cluster.rs +++ b/shotover/src/transforms/redis/sink_cluster.rs @@ -17,7 +17,7 @@ use futures::stream::FuturesOrdered; use futures::stream::FuturesUnordered; use futures::{StreamExt, TryFutureExt}; use itertools::Itertools; -use metrics::{counter, register_counter}; +use metrics::counter; use rand::rngs::SmallRng; use rand::seq::IteratorRandom; use rand::SeedableRng; @@ -159,7 +159,7 @@ impl RedisSinkCluster { token: None, }; - register_counter!("shotover_failed_requests_count", "chain" => chain_name, "transform" => sink_cluster.get_name()); + counter!("shotover_failed_requests_count", "chain" => chain_name, "transform" => sink_cluster.get_name()); sink_cluster } @@ -604,7 +604,7 @@ impl RedisSinkCluster { #[inline(always)] fn send_error_response(&self, message: &str) -> Result { - counter!("shotover_failed_requests_count", 1, "chain" => self.chain_name.clone(), "transform" => self.get_name()); + counter!("shotover_failed_requests_count", "chain" => self.chain_name.clone(), "transform" => self.get_name()).increment(1); short_circuit(RedisFrame::Error(message.into())) } diff --git a/shotover/src/transforms/redis/sink_single.rs b/shotover/src/transforms/redis/sink_single.rs index 54af80b13..9521de68b 100644 --- a/shotover/src/transforms/redis/sink_single.rs +++ b/shotover/src/transforms/redis/sink_single.rs @@ -10,7 +10,7 @@ use crate::transforms::{Transform, TransformBuilder, TransformConfig, Wrapper}; use anyhow::{anyhow, Result}; use async_trait::async_trait; use futures::{FutureExt, SinkExt, StreamExt}; -use metrics::{register_counter, Counter}; +use metrics::{counter, Counter}; use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::pin::Pin; @@ -59,7 +59,7 @@ impl RedisSinkSingleBuilder { chain_name: String, connect_timeout_ms: u64, ) -> Self { - let failed_requests = register_counter!("shotover_failed_requests_count", "chain" => chain_name, "transform" => "RedisSinkSingle"); + let failed_requests = counter!("shotover_failed_requests_count", "chain" => chain_name, "transform" => "RedisSinkSingle"); let connect_timeout = Duration::from_millis(connect_timeout_ms); RedisSinkSingleBuilder { diff --git a/shotover/src/transforms/tee.rs b/shotover/src/transforms/tee.rs index 38c7911e2..aaca1f5cd 100644 --- a/shotover/src/transforms/tee.rs +++ b/shotover/src/transforms/tee.rs @@ -10,7 +10,7 @@ use hyper::{ service::{make_service_fn, service_fn}, Method, Request, StatusCode, {Body, Response, Server}, }; -use metrics::{register_counter, Counter}; +use metrics::{counter, Counter}; use serde::{Deserialize, Serialize}; use std::fmt; use std::sync::atomic::Ordering; @@ -49,8 +49,7 @@ impl TeeBuilder { tokio::spawn(chain_switch_listener.async_run(result_source.clone())); } - let dropped_messages = - register_counter!("shotover_tee_dropped_messages_count", "chain" => "Tee"); + let dropped_messages = counter!("shotover_tee_dropped_messages_count", "chain" => "Tee"); TeeBuilder { tx,