From e31ac508d404700c35d99936028a5fd74749c335 Mon Sep 17 00:00:00 2001 From: Age Manning Date: Mon, 28 Oct 2024 20:41:45 +1100 Subject: [PATCH] Modularize tracing executor and metrics rename (#6424) * Tracing executor and metrics rename * Appease clippy * Merge branch 'unstable' into modularise-task-executor --- Cargo.lock | 373 +++++++++--------- Cargo.toml | 5 +- beacon_node/beacon_chain/Cargo.toml | 2 +- .../beacon_chain/src/block_verification.rs | 2 +- beacon_node/beacon_chain/src/metrics.rs | 2 +- .../tests/attestation_production.rs | 2 +- beacon_node/beacon_processor/Cargo.toml | 2 +- beacon_node/beacon_processor/src/metrics.rs | 2 +- beacon_node/client/Cargo.toml | 2 +- beacon_node/client/src/metrics.rs | 2 +- beacon_node/eth1/Cargo.toml | 2 +- beacon_node/eth1/src/metrics.rs | 2 +- beacon_node/execution_layer/Cargo.toml | 2 +- beacon_node/execution_layer/src/metrics.rs | 2 +- beacon_node/http_api/Cargo.toml | 2 +- beacon_node/http_api/src/metrics.rs | 2 +- beacon_node/http_metrics/Cargo.toml | 2 +- beacon_node/http_metrics/src/metrics.rs | 8 +- beacon_node/lighthouse_network/Cargo.toml | 2 +- beacon_node/lighthouse_network/src/metrics.rs | 2 +- beacon_node/network/Cargo.toml | 2 +- beacon_node/network/src/metrics.rs | 2 +- .../network/src/sync/range_sync/chain.rs | 2 +- beacon_node/operation_pool/Cargo.toml | 4 +- beacon_node/operation_pool/src/metrics.rs | 2 +- beacon_node/store/Cargo.toml | 2 +- beacon_node/store/src/metrics.rs | 2 +- common/lighthouse_metrics/Cargo.toml | 10 - common/logging/Cargo.toml | 2 +- common/logging/src/lib.rs | 4 +- common/logging/src/tracing_metrics_layer.rs | 1 - common/malloc_utils/Cargo.toml | 2 +- common/malloc_utils/src/glibc.rs | 53 ++- common/malloc_utils/src/jemalloc.rs | 16 +- common/metrics/Cargo.toml | 7 + .../src/lib.rs | 4 +- common/monitoring_api/Cargo.toml | 2 +- common/monitoring_api/src/gather.rs | 4 +- common/slot_clock/Cargo.toml | 2 +- common/slot_clock/src/metrics.rs | 2 +- common/task_executor/Cargo.toml | 16 +- common/task_executor/src/lib.rs | 88 ++++- common/task_executor/src/metrics.rs | 2 +- common/warp_utils/Cargo.toml | 2 +- common/warp_utils/src/metrics.rs | 2 +- consensus/fork_choice/Cargo.toml | 2 +- consensus/fork_choice/src/metrics.rs | 2 +- consensus/state_processing/Cargo.toml | 2 +- .../update_progressive_balances_cache.rs | 2 +- consensus/state_processing/src/metrics.rs | 2 +- lighthouse/Cargo.toml | 2 +- lighthouse/src/metrics.rs | 2 +- slasher/Cargo.toml | 2 +- slasher/src/metrics.rs | 2 +- validator_client/Cargo.toml | 2 +- validator_client/src/http_metrics/metrics.rs | 6 +- .../src/initialized_validators.rs | 2 +- validator_client/src/lib.rs | 2 +- validator_client/src/notifier.rs | 2 +- 59 files changed, 364 insertions(+), 323 deletions(-) delete mode 100644 common/lighthouse_metrics/Cargo.toml create mode 100644 common/metrics/Cargo.toml rename common/{lighthouse_metrics => metrics}/src/lib.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index b12df12265d..18602ff8781 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,19 +59,13 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -161,9 +155,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-consensus" -version = "0.3.1" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4177d135789e282e925092be8939d421b701c6d92c0a16679faa659d9166289d" +checksum = "629b62e38d471cc15fea534eb7283d2f8a4e8bdb1811bcc5d66dda6cfce6fae1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -193,9 +187,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.3.1" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "499ee14d296a133d142efd215eb36bf96124829fe91cf8f5d4e5ccdd381eae00" +checksum = "f923dd5fca5f67a43d81ed3ebad0880bd41f6dd0ada930030353ac356c54cd0f" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -210,9 +204,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a767e59c86900dd7c3ce3ecef04f3ace5ac9631ee150beb8b7d22f7fa3bbb2d7" +checksum = "411aff151f2a73124ee473708e82ed51b2535f68928b6a1caa8bc1246ae6f7cd" dependencies = [ "alloy-rlp", "arbitrary", @@ -220,11 +214,11 @@ dependencies = [ "cfg-if", "const-hex", "derive_arbitrary", - "derive_more 0.99.18", + "derive_more 1.0.0", "getrandom", "hex-literal", "itoa", - "k256 0.13.3", + "k256 0.13.4", "keccak-asm", "proptest", "proptest-derive", @@ -328,9 +322,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "arbitrary" @@ -488,9 +482,9 @@ checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" @@ -567,7 +561,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 0.38.35", + "rustix 0.38.37", "slab", "tracing", "windows-sys 0.59.0", @@ -660,9 +654,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" dependencies = [ "async-trait", "axum-core", @@ -686,7 +680,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -694,9 +688,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" dependencies = [ "async-trait", "bytes", @@ -707,7 +701,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", "tracing", @@ -715,17 +709,17 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", - "miniz_oxide 0.7.4", + "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -794,12 +788,12 @@ dependencies = [ "int_to_bytes", "itertools 0.10.5", "kzg", - "lighthouse_metrics", "lighthouse_version", "logging", "lru", "maplit", "merkle_proof", + "metrics", "oneshot_broadcast", "operation_pool", "parking_lot 0.12.3", @@ -870,9 +864,9 @@ dependencies = [ "fnv", "futures", "itertools 0.10.5", - "lighthouse_metrics", "lighthouse_network", "logging", + "metrics", "num_cpus", "parking_lot 0.12.3", "serde", @@ -1125,9 +1119,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -1208,9 +1202,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.15" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" dependencies = [ "jobserver", "libc", @@ -1334,9 +1328,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -1344,9 +1338,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -1357,9 +1351,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -1409,8 +1403,8 @@ dependencies = [ "http_api", "http_metrics", "kzg", - "lighthouse_metrics", "lighthouse_network", + "metrics", "monitoring_api", "network", "operation_pool", @@ -1529,9 +1523,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -2049,13 +2043,14 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.77", + "unicode-xid", ] [[package]] name = "diesel" -version = "2.2.3" +version = "2.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e13bab2796f412722112327f3e575601a3e9cdcbe426f0d30dbf43f3f5dc71" +checksum = "158fe8e2e68695bd615d7e4f3227c0727b151330d3e253b525086c348d055d5e" dependencies = [ "bitflags 2.6.0", "byteorder", @@ -2387,7 +2382,7 @@ dependencies = [ "bytes", "ed25519-dalek", "hex", - "k256 0.13.3", + "k256 0.13.4", "log", "rand", "serde", @@ -2397,11 +2392,11 @@ dependencies = [ [[package]] name = "enum-as-inner" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.77", @@ -2497,9 +2492,9 @@ dependencies = [ "ethereum_ssz_derive", "execution_layer", "futures", - "lighthouse_metrics", "logging", "merkle_proof", + "metrics", "parking_lot 0.12.3", "sensitive_url", "serde", @@ -2997,10 +2992,10 @@ dependencies = [ "jsonwebtoken", "keccak-hash", "kzg", - "lighthouse_metrics", "lighthouse_version", "logging", "lru", + "metrics", "parking_lot 0.12.3", "pretty_reqwest_error", "rand", @@ -3167,7 +3162,7 @@ checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide 0.8.0", + "miniz_oxide", ] [[package]] @@ -3198,7 +3193,7 @@ dependencies = [ "beacon_chain", "ethereum_ssz", "ethereum_ssz_derive", - "lighthouse_metrics", + "metrics", "proto_array", "slog", "state_processing", @@ -3325,7 +3320,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", ] @@ -3442,9 +3437,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "git-version" @@ -3871,11 +3866,11 @@ dependencies = [ "futures", "genesis", "hex", - "lighthouse_metrics", "lighthouse_network", "lighthouse_version", "logging", "lru", + "metrics", "network", "operation_pool", "parking_lot 0.12.3", @@ -3905,11 +3900,11 @@ name = "http_metrics" version = "0.1.0" dependencies = [ "beacon_chain", - "lighthouse_metrics", "lighthouse_network", "lighthouse_version", "logging", "malloc_utils", + "metrics", "reqwest", "serde", "slog", @@ -4011,9 +4006,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" dependencies = [ "bytes", "futures-util", @@ -4022,13 +4017,15 @@ dependencies = [ "hyper 1.4.1", "pin-project-lite", "tokio", + "tower 0.4.13", + "tower-service", ] [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -4267,9 +4264,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is-terminal" @@ -4369,9 +4366,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa 0.16.9", @@ -4392,9 +4389,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422fbc7ff2f2f5bdffeb07718e5a5324dca72b0c9293d50df4026652385e3314" +checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -4825,7 +4822,7 @@ dependencies = [ "quinn", "rand", "ring 0.17.8", - "rustls 0.23.12", + "rustls 0.23.13", "socket2 0.5.7", "thiserror", "tokio", @@ -4897,7 +4894,7 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.17.8", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-webpki 0.101.7", "thiserror", "x509-parser", @@ -5035,11 +5032,11 @@ dependencies = [ "eth2_network_config", "ethereum_hashing", "futures", - "lighthouse_metrics", "lighthouse_network", "lighthouse_version", "logging", "malloc_utils", + "metrics", "sensitive_url", "serde", "serde_json", @@ -5056,13 +5053,6 @@ dependencies = [ "validator_manager", ] -[[package]] -name = "lighthouse_metrics" -version = "0.2.0" -dependencies = [ - "prometheus", -] - [[package]] name = "lighthouse_network" version = "0.2.0" @@ -5086,11 +5076,11 @@ dependencies = [ "itertools 0.10.5", "libp2p", "libp2p-mplex", - "lighthouse_metrics", "lighthouse_version", "logging", "lru", "lru_cache", + "metrics", "parking_lot 0.12.3", "prometheus-client", "quickcheck", @@ -5196,7 +5186,7 @@ name = "logging" version = "0.2.0" dependencies = [ "chrono", - "lighthouse_metrics", + "metrics", "parking_lot 0.12.3", "serde", "serde_json", @@ -5252,7 +5242,7 @@ name = "malloc_utils" version = "0.1.0" dependencies = [ "libc", - "lighthouse_metrics", + "metrics", "parking_lot 0.12.3", "tikv-jemalloc-ctl", "tikv-jemallocator", @@ -5368,6 +5358,13 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "metrics" +version = "0.2.0" +dependencies = [ + "prometheus", +] + [[package]] name = "migrations_internals" version = "2.2.0" @@ -5434,15 +5431,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -5475,8 +5463,8 @@ name = "monitoring_api" version = "0.1.0" dependencies = [ "eth2", - "lighthouse_metrics", "lighthouse_version", + "metrics", "regex", "reqwest", "sensitive_url", @@ -5657,11 +5645,11 @@ dependencies = [ "igd-next", "itertools 0.10.5", "kzg", - "lighthouse_metrics", "lighthouse_network", "logging", "lru_cache", "matches", + "metrics", "operation_pool", "parking_lot 0.12.3", "rand", @@ -5931,9 +5919,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.3.1+3.3.1" +version = "300.3.2+3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" +checksum = "a211a18d945ef7e648cc6e0058f4c548ee46aab922ea203e0d30e966ea23647b" dependencies = [ "cc", ] @@ -5961,8 +5949,8 @@ dependencies = [ "ethereum_ssz", "ethereum_ssz_derive", "itertools 0.10.5", - "lighthouse_metrics", "maplit", + "metrics", "parking_lot 0.12.3", "rand", "rayon", @@ -6054,9 +6042,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" @@ -6101,7 +6089,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.3", + "redox_syscall 0.5.4", "smallvec", "windows-targets 0.52.6", ] @@ -6171,9 +6159,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" dependencies = [ "memchr", "thiserror", @@ -6274,9 +6262,9 @@ checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -6287,15 +6275,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -6310,7 +6298,7 @@ dependencies = [ "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.35", + "rustix 0.38.37", "tracing", "windows-sys 0.59.0", ] @@ -6358,9 +6346,9 @@ dependencies = [ [[package]] name = "postgres-types" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02048d9e032fb3cc3413bbf7b83a15d84a5d419778e2628751896d856498eee9" +checksum = "f66ea23a2d0e5734297357705193335e0a957696f34bed2f2faefacb2fec336f" dependencies = [ "bytes", "fallible-iterator", @@ -6384,9 +6372,9 @@ dependencies = [ [[package]] name = "pq-sys" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24ff9e4cf6945c988f0db7005d87747bf72864965c3529d259ad155ac41d584" +checksum = "f6cc05d7ea95200187117196eee9edd0644424911821aeb28a18ce60ea0b8793" dependencies = [ "vcpkg", ] @@ -6451,7 +6439,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.22.20", + "toml_edit 0.22.21", ] [[package]] @@ -6636,9 +6624,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d2fb862b7ba45e615c1429def928f2e15f815bdf933b27a2d3824e224c1f46" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ "bytes", "futures-io", @@ -6646,7 +6634,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.0.0", - "rustls 0.23.12", + "rustls 0.23.13", "socket2 0.5.7", "thiserror", "tokio", @@ -6655,15 +6643,15 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.7" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0a9b3a42929fad8a7c3de7f86ce0814cfa893328157672680e9fb1145549c5" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand", "ring 0.17.8", "rustc-hash 2.0.0", - "rustls 0.23.12", + "rustls 0.23.13", "slab", "thiserror", "tinyvec", @@ -6672,15 +6660,15 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", "socket2 0.5.7", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6816,18 +6804,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" dependencies = [ "bitflags 2.6.0", ] @@ -7181,9 +7160,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -7213,21 +7192,21 @@ dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] @@ -7269,9 +7248,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -7361,11 +7340,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -7454,9 +7433,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -7505,9 +7484,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -7524,9 +7503,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -7535,9 +7514,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -7681,9 +7660,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d79b758b7cb2085612b11a235055e485605a5103faccdd633f35bd7aee69dd" +checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" dependencies = [ "cc", "cfg-if", @@ -7791,12 +7770,12 @@ dependencies = [ "filesystem", "flate2", "libmdbx", - "lighthouse_metrics", "lmdb-rkv", "lmdb-rkv-sys", "logging", "lru", "maplit", + "metrics", "parking_lot 0.12.3", "rand", "rayon", @@ -7952,7 +7931,7 @@ dependencies = [ name = "slot_clock" version = "0.2.0" dependencies = [ - "lighthouse_metrics", + "metrics", "parking_lot 0.12.3", "types", ] @@ -8080,8 +8059,8 @@ dependencies = [ "int_to_bytes", "integer-sqrt", "itertools 0.10.5", - "lighthouse_metrics", "merkle_proof", + "metrics", "rand", "rayon", "safe_arith", @@ -8121,8 +8100,8 @@ dependencies = [ "ethereum_ssz_derive", "itertools 0.10.5", "leveldb", - "lighthouse_metrics", "lru", + "metrics", "parking_lot 0.12.3", "safe_arith", "serde", @@ -8332,11 +8311,12 @@ version = "0.1.0" dependencies = [ "async-channel", "futures", - "lighthouse_metrics", "logging", + "metrics", "slog", "sloggers", "tokio", + "tracing", ] [[package]] @@ -8348,7 +8328,7 @@ dependencies = [ "cfg-if", "fastrand", "once_cell", - "rustix 0.38.35", + "rustix 0.38.37", "windows-sys 0.59.0", ] @@ -8378,7 +8358,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.38.35", + "rustix 0.38.37", "windows-sys 0.48.0", ] @@ -8417,18 +8397,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -8630,9 +8610,9 @@ dependencies = [ [[package]] name = "tokio-postgres" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03adcf0147e203b6032c0b2d30be1415ba03bc348901f3ff1cc0df6a733e60c3" +checksum = "3b5d3742945bc7d7f210693b0c58ae542c6fd47b17adbbda0885f3dcb34a6bdb" dependencies = [ "async-trait", "byteorder", @@ -8677,9 +8657,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -8689,9 +8669,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -8720,7 +8700,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.20", + "toml_edit 0.22.21", ] [[package]] @@ -8745,9 +8725,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" dependencies = [ "indexmap 2.5.0", "serde", @@ -8769,6 +8749,21 @@ dependencies = [ "tokio", "tower-layer", "tower-service", +] + +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", "tracing", ] @@ -9042,15 +9037,15 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -9063,9 +9058,9 @@ checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "universal-hash" @@ -9170,11 +9165,11 @@ dependencies = [ "hyper 1.4.1", "itertools 0.10.5", "libsecp256k1", - "lighthouse_metrics", "lighthouse_version", "lockfile", "logging", "malloc_utils", + "metrics", "monitoring_api", "parking_lot 0.12.3", "rand", @@ -9338,7 +9333,7 @@ dependencies = [ "bytes", "eth2", "headers", - "lighthouse_metrics", + "metrics", "safe_arith", "serde", "serde_array_query", @@ -9544,11 +9539,11 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "whoami" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" dependencies = [ - "redox_syscall 0.4.1", + "redox_syscall 0.5.4", "wasite", "web-sys", ] @@ -9943,9 +9938,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a77ee7c0de333dcc6da69b177380a0b81e0dacfa4f7344c465a36871ee601" +checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26" [[package]] name = "xmltree" diff --git a/Cargo.toml b/Cargo.toml index 94ac8e13ff1..7094ff60776 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ members = [ "common/eth2_interop_keypairs", "common/eth2_network_config", "common/eth2_wallet_manager", - "common/lighthouse_metrics", + "common/metrics", "common/lighthouse_version", "common/lockfile", "common/logging", @@ -141,6 +141,7 @@ milhouse = "0.3" num_cpus = "1" parking_lot = "0.12" paste = "1" +prometheus = "0.13" quickcheck = "1" quickcheck_macros = "1" quote = "1" @@ -213,7 +214,7 @@ gossipsub = { path = "beacon_node/lighthouse_network/gossipsub/" } http_api = { path = "beacon_node/http_api" } int_to_bytes = { path = "consensus/int_to_bytes" } kzg = { path = "crypto/kzg" } -lighthouse_metrics = { path = "common/lighthouse_metrics" } +metrics = { path = "common/metrics" } lighthouse_network = { path = "beacon_node/lighthouse_network" } lighthouse_version = { path = "common/lighthouse_version" } lockfile = { path = "common/lockfile" } diff --git a/beacon_node/beacon_chain/Cargo.toml b/beacon_node/beacon_chain/Cargo.toml index 0dc941df90c..b0fa0131808 100644 --- a/beacon_node/beacon_chain/Cargo.toml +++ b/beacon_node/beacon_chain/Cargo.toml @@ -42,7 +42,7 @@ hex = { workspace = true } int_to_bytes = { workspace = true } itertools = { workspace = true } kzg = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } lighthouse_version = { workspace = true } logging = { workspace = true } lru = { workspace = true } diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index 661b539fbe1..527462ab64c 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -70,7 +70,7 @@ use derivative::Derivative; use eth2::types::{BlockGossip, EventKind}; use execution_layer::PayloadStatus; pub use fork_choice::{AttestationFromBlock, PayloadVerificationStatus}; -use lighthouse_metrics::TryExt; +use metrics::TryExt; use parking_lot::RwLockReadGuard; use proto_array::Block as ProtoBlock; use safe_arith::ArithError; diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index 0b5608f0843..f73775d678f 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -2,7 +2,7 @@ use crate::observed_attesters::SlotSubcommitteeIndex; use crate::types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT; use crate::{BeaconChain, BeaconChainError, BeaconChainTypes}; use bls::FixedBytesExtended; -pub use lighthouse_metrics::*; +pub use metrics::*; use slot_clock::SlotClock; use std::sync::LazyLock; use types::{BeaconState, Epoch, EthSpec, Hash256, Slot}; diff --git a/beacon_node/beacon_chain/tests/attestation_production.rs b/beacon_node/beacon_chain/tests/attestation_production.rs index e1f2cbb284f..0b121356b9d 100644 --- a/beacon_node/beacon_chain/tests/attestation_production.rs +++ b/beacon_node/beacon_chain/tests/attestation_production.rs @@ -86,7 +86,7 @@ async fn produces_attestations_from_attestation_simulator_service() { let expected_miss_metrics_count = 0; let expected_hit_metrics_count = num_blocks_produced - UNAGGREGATED_ATTESTATION_LAG_SLOTS as u64; - lighthouse_metrics::gather().iter().for_each(|mf| { + metrics::gather().iter().for_each(|mf| { if hit_prometheus_metrics.contains(&mf.get_name()) { assert_eq!( mf.get_metric()[0].get_counter().get_value() as u64, diff --git a/beacon_node/beacon_processor/Cargo.toml b/beacon_node/beacon_processor/Cargo.toml index 554010be07b..9273137bf6d 100644 --- a/beacon_node/beacon_processor/Cargo.toml +++ b/beacon_node/beacon_processor/Cargo.toml @@ -16,7 +16,7 @@ task_executor = { workspace = true } slot_clock = { workspace = true } lighthouse_network = { workspace = true } types = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } parking_lot = { workspace = true } num_cpus = { workspace = true } serde = { workspace = true } diff --git a/beacon_node/beacon_processor/src/metrics.rs b/beacon_node/beacon_processor/src/metrics.rs index 0a7bdba18d1..fc8c712f4e7 100644 --- a/beacon_node/beacon_processor/src/metrics.rs +++ b/beacon_node/beacon_processor/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; /* diff --git a/beacon_node/client/Cargo.toml b/beacon_node/client/Cargo.toml index 06f7763c8a4..21a6e42cc50 100644 --- a/beacon_node/client/Cargo.toml +++ b/beacon_node/client/Cargo.toml @@ -33,7 +33,7 @@ sensitive_url = { workspace = true } genesis = { workspace = true } task_executor = { workspace = true } environment = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } time = "0.3.5" directory = { workspace = true } http_api = { workspace = true } diff --git a/beacon_node/client/src/metrics.rs b/beacon_node/client/src/metrics.rs index ebc4fe70a71..e5c07baddc2 100644 --- a/beacon_node/client/src/metrics.rs +++ b/beacon_node/client/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; pub static SYNC_SLOTS_PER_SECOND: LazyLock> = LazyLock::new(|| { diff --git a/beacon_node/eth1/Cargo.toml b/beacon_node/eth1/Cargo.toml index 4910cfd2e1b..50400a77e06 100644 --- a/beacon_node/eth1/Cargo.toml +++ b/beacon_node/eth1/Cargo.toml @@ -25,7 +25,7 @@ logging = { workspace = true } superstruct = { workspace = true } tokio = { workspace = true } state_processing = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } task_executor = { workspace = true } eth2 = { workspace = true } sensitive_url = { workspace = true } diff --git a/beacon_node/eth1/src/metrics.rs b/beacon_node/eth1/src/metrics.rs index 9a11e7a6920..1df4ba0df9a 100644 --- a/beacon_node/eth1/src/metrics.rs +++ b/beacon_node/eth1/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; /* diff --git a/beacon_node/execution_layer/Cargo.toml b/beacon_node/execution_layer/Cargo.toml index 843a7b83cb7..0ef101fae7c 100644 --- a/beacon_node/execution_layer/Cargo.toml +++ b/beacon_node/execution_layer/Cargo.toml @@ -35,7 +35,7 @@ slot_clock = { workspace = true } tempfile = { workspace = true } rand = { workspace = true } zeroize = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } ethers-core = { workspace = true } builder_client = { path = "../builder_client" } fork_choice = { workspace = true } diff --git a/beacon_node/execution_layer/src/metrics.rs b/beacon_node/execution_layer/src/metrics.rs index 184031af4d0..ab1a22677f3 100644 --- a/beacon_node/execution_layer/src/metrics.rs +++ b/beacon_node/execution_layer/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; pub const HIT: &str = "hit"; diff --git a/beacon_node/http_api/Cargo.toml b/beacon_node/http_api/Cargo.toml index f3779f0e4ac..638fe0f2192 100644 --- a/beacon_node/http_api/Cargo.toml +++ b/beacon_node/http_api/Cargo.toml @@ -20,7 +20,7 @@ lighthouse_network = { workspace = true } eth1 = { workspace = true } state_processing = { workspace = true } lighthouse_version = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } warp_utils = { workspace = true } slot_clock = { workspace = true } ethereum_ssz = { workspace = true } diff --git a/beacon_node/http_api/src/metrics.rs b/beacon_node/http_api/src/metrics.rs index 970eef8dd07..b6a53b26c69 100644 --- a/beacon_node/http_api/src/metrics.rs +++ b/beacon_node/http_api/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; pub static HTTP_API_PATHS_TOTAL: LazyLock> = LazyLock::new(|| { diff --git a/beacon_node/http_metrics/Cargo.toml b/beacon_node/http_metrics/Cargo.toml index f835d13fb66..97ba72a2ac6 100644 --- a/beacon_node/http_metrics/Cargo.toml +++ b/beacon_node/http_metrics/Cargo.toml @@ -14,7 +14,7 @@ beacon_chain = { workspace = true } store = { workspace = true } lighthouse_network = { workspace = true } slot_clock = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } lighthouse_version = { workspace = true } warp_utils = { workspace = true } malloc_utils = { workspace = true } diff --git a/beacon_node/http_metrics/src/metrics.rs b/beacon_node/http_metrics/src/metrics.rs index d68efff4320..d751c51e4c9 100644 --- a/beacon_node/http_metrics/src/metrics.rs +++ b/beacon_node/http_metrics/src/metrics.rs @@ -1,8 +1,8 @@ use crate::Context; use beacon_chain::BeaconChainTypes; -use lighthouse_metrics::TextEncoder; use lighthouse_network::prometheus_client::encoding::text::encode; use malloc_utils::scrape_allocator_metrics; +use metrics::TextEncoder; pub fn gather_prometheus_metrics( ctx: &Context, @@ -17,13 +17,13 @@ pub fn gather_prometheus_metrics( // - Statically updated: things which are only updated at the time of the scrape (used where we // can avoid cluttering up code with metrics calls). // - // The `lighthouse_metrics` crate has a `DEFAULT_REGISTRY` global singleton + // The `metrics` crate has a `DEFAULT_REGISTRY` global singleton // which keeps the state of all the metrics. Dynamically updated things will already be // up-to-date in the registry (because they update themselves) however statically updated // things need to be "scraped". // // We proceed by, first updating all the static metrics using `scrape_for_metrics(..)`. Then, - // using `lighthouse_metrics::gather(..)` to collect the global `DEFAULT_REGISTRY` metrics into + // using `metrics::gather(..)` to collect the global `DEFAULT_REGISTRY` metrics into // a string that can be returned via HTTP. if let Some(beacon_chain) = ctx.chain.as_ref() { @@ -48,7 +48,7 @@ pub fn gather_prometheus_metrics( } encoder - .encode_utf8(&lighthouse_metrics::gather(), &mut buffer) + .encode_utf8(&metrics::gather(), &mut buffer) .unwrap(); // encode gossipsub metrics also if they exist if let Some(registry) = ctx.gossipsub_registry.as_ref() { diff --git a/beacon_node/lighthouse_network/Cargo.toml b/beacon_node/lighthouse_network/Cargo.toml index b0f5b9a5e1c..c4fad997025 100644 --- a/beacon_node/lighthouse_network/Cargo.toml +++ b/beacon_node/lighthouse_network/Cargo.toml @@ -21,7 +21,7 @@ futures = { workspace = true } error-chain = { workspace = true } dirs = { workspace = true } fnv = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } smallvec = { workspace = true } tokio-io-timeout = "1" lru = { workspace = true } diff --git a/beacon_node/lighthouse_network/src/metrics.rs b/beacon_node/lighthouse_network/src/metrics.rs index c3f64a5a1f4..15445c7d645 100644 --- a/beacon_node/lighthouse_network/src/metrics.rs +++ b/beacon_node/lighthouse_network/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; pub static NAT_OPEN: LazyLock> = LazyLock::new(|| { diff --git a/beacon_node/network/Cargo.toml b/beacon_node/network/Cargo.toml index 6d61bffe3de..500cd23faeb 100644 --- a/beacon_node/network/Cargo.toml +++ b/beacon_node/network/Cargo.toml @@ -38,7 +38,7 @@ smallvec = { workspace = true } rand = { workspace = true } fnv = { workspace = true } alloy-rlp = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } logging = { workspace = true } task_executor = { workspace = true } igd-next = "0.14" diff --git a/beacon_node/network/src/metrics.rs b/beacon_node/network/src/metrics.rs index 9e42aa8e924..4b7e8a50a36 100644 --- a/beacon_node/network/src/metrics.rs +++ b/beacon_node/network/src/metrics.rs @@ -5,11 +5,11 @@ use beacon_chain::{ sync_committee_verification::Error as SyncCommitteeError, }; use fnv::FnvHashMap; -pub use lighthouse_metrics::*; use lighthouse_network::{ peer_manager::peerdb::client::ClientKind, types::GossipKind, GossipTopic, Gossipsub, NetworkGlobals, }; +pub use metrics::*; use std::sync::{Arc, LazyLock}; use strum::IntoEnumIterator; use types::EthSpec; diff --git a/beacon_node/network/src/sync/range_sync/chain.rs b/beacon_node/network/src/sync/range_sync/chain.rs index 732e4a7bd16..51d9d9da37f 100644 --- a/beacon_node/network/src/sync/range_sync/chain.rs +++ b/beacon_node/network/src/sync/range_sync/chain.rs @@ -8,9 +8,9 @@ use crate::sync::{network_context::SyncNetworkContext, BatchOperationOutcome, Ba use beacon_chain::block_verification_types::RpcBlock; use beacon_chain::BeaconChainTypes; use fnv::FnvHashMap; -use lighthouse_metrics::set_int_gauge; use lighthouse_network::service::api_types::Id; use lighthouse_network::{PeerAction, PeerId}; +use metrics::set_int_gauge; use rand::seq::SliceRandom; use rand::Rng; use slog::{crit, debug, o, warn}; diff --git a/beacon_node/operation_pool/Cargo.toml b/beacon_node/operation_pool/Cargo.toml index cbf6284f2ae..5b48e3f0d88 100644 --- a/beacon_node/operation_pool/Cargo.toml +++ b/beacon_node/operation_pool/Cargo.toml @@ -7,7 +7,7 @@ edition = { workspace = true } [dependencies] derivative = { workspace = true } itertools = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } parking_lot = { workspace = true } types = { workspace = true } state_processing = { workspace = true } @@ -25,4 +25,4 @@ tokio = { workspace = true } maplit = { workspace = true } [features] -portable = ["beacon_chain/portable"] \ No newline at end of file +portable = ["beacon_chain/portable"] diff --git a/beacon_node/operation_pool/src/metrics.rs b/beacon_node/operation_pool/src/metrics.rs index e2a8b43ed17..14088688e5e 100644 --- a/beacon_node/operation_pool/src/metrics.rs +++ b/beacon_node/operation_pool/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; pub static BUILD_REWARD_CACHE_TIME: LazyLock> = LazyLock::new(|| { diff --git a/beacon_node/store/Cargo.toml b/beacon_node/store/Cargo.toml index cdb18b3b9cb..aac1ee26e14 100644 --- a/beacon_node/store/Cargo.toml +++ b/beacon_node/store/Cargo.toml @@ -20,7 +20,7 @@ safe_arith = { workspace = true } state_processing = { workspace = true } slog = { workspace = true } serde = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } lru = { workspace = true } sloggers = { workspace = true } directory = { workspace = true } diff --git a/beacon_node/store/src/metrics.rs b/beacon_node/store/src/metrics.rs index 902c440be86..1921b9b3273 100644 --- a/beacon_node/store/src/metrics.rs +++ b/beacon_node/store/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::{set_gauge, try_create_int_gauge, *}; +pub use metrics::{set_gauge, try_create_int_gauge, *}; use directory::size_of_dir; use std::path::Path; diff --git a/common/lighthouse_metrics/Cargo.toml b/common/lighthouse_metrics/Cargo.toml deleted file mode 100644 index fe966f4a9c6..00000000000 --- a/common/lighthouse_metrics/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "lighthouse_metrics" -version = "0.2.0" -authors = ["Paul Hauner "] -edition = { workspace = true } - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -prometheus = "0.13.0" diff --git a/common/logging/Cargo.toml b/common/logging/Cargo.toml index cac6d073f25..73cbdf44d42 100644 --- a/common/logging/Cargo.toml +++ b/common/logging/Cargo.toml @@ -9,7 +9,7 @@ test_logger = [] # Print log output to stderr when running tests instead of drop [dependencies] chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } parking_lot = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/common/logging/src/lib.rs b/common/logging/src/lib.rs index 0df03c17d01..4bb37392984 100644 --- a/common/logging/src/lib.rs +++ b/common/logging/src/lib.rs @@ -1,6 +1,4 @@ -use lighthouse_metrics::{ - inc_counter, try_create_int_counter, IntCounter, Result as MetricsResult, -}; +use metrics::{inc_counter, try_create_int_counter, IntCounter, Result as MetricsResult}; use slog::Logger; use slog_term::Decorator; use std::io::{Result, Write}; diff --git a/common/logging/src/tracing_metrics_layer.rs b/common/logging/src/tracing_metrics_layer.rs index 89a1f4d1f16..5d272adbf59 100644 --- a/common/logging/src/tracing_metrics_layer.rs +++ b/common/logging/src/tracing_metrics_layer.rs @@ -1,6 +1,5 @@ //! Exposes [`MetricsLayer`]: A tracing layer that registers metrics of logging events. -use lighthouse_metrics as metrics; use std::sync::LazyLock; use tracing_log::NormalizeEvent; diff --git a/common/malloc_utils/Cargo.toml b/common/malloc_utils/Cargo.toml index b91e68c518e..79a07eed166 100644 --- a/common/malloc_utils/Cargo.toml +++ b/common/malloc_utils/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Paul Hauner "] edition = { workspace = true } [dependencies] -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } libc = "0.2.79" parking_lot = { workspace = true } tikv-jemalloc-ctl = { version = "0.6.0", optional = true, features = ["stats"] } diff --git a/common/malloc_utils/src/glibc.rs b/common/malloc_utils/src/glibc.rs index 41d8d28291d..30313d06723 100644 --- a/common/malloc_utils/src/glibc.rs +++ b/common/malloc_utils/src/glibc.rs @@ -4,7 +4,7 @@ //! https://www.gnu.org/software/libc/manual/html_node/The-GNU-Allocator.html //! //! These functions are generally only suitable for Linux systems. -use lighthouse_metrics::*; +use metrics::*; use parking_lot::Mutex; use std::env; use std::os::raw::c_int; @@ -38,60 +38,57 @@ pub static GLOBAL_LOCK: LazyLock> = LazyLock::new(|| <_>::default()); // Metrics for the malloc. For more information, see: // // https://man7.org/linux/man-pages/man3/mallinfo.3.html -pub static MALLINFO_ARENA: LazyLock> = LazyLock::new(|| { +pub static MALLINFO_ARENA: LazyLock> = LazyLock::new(|| { try_create_int_gauge( "mallinfo_arena", "The total amount of memory allocated by means other than mmap(2). \ This figure includes both in-use blocks and blocks on the free list.", ) }); -pub static MALLINFO_ORDBLKS: LazyLock> = LazyLock::new(|| { +pub static MALLINFO_ORDBLKS: LazyLock> = LazyLock::new(|| { try_create_int_gauge( "mallinfo_ordblks", "The number of ordinary (i.e., non-fastbin) free blocks.", ) }); -pub static MALLINFO_SMBLKS: LazyLock> = +pub static MALLINFO_SMBLKS: LazyLock> = LazyLock::new(|| try_create_int_gauge("mallinfo_smblks", "The number of fastbin free blocks.")); -pub static MALLINFO_HBLKS: LazyLock> = LazyLock::new(|| { +pub static MALLINFO_HBLKS: LazyLock> = LazyLock::new(|| { try_create_int_gauge( "mallinfo_hblks", "The number of blocks currently allocated using mmap.", ) }); -pub static MALLINFO_HBLKHD: LazyLock> = LazyLock::new(|| { +pub static MALLINFO_HBLKHD: LazyLock> = LazyLock::new(|| { try_create_int_gauge( "mallinfo_hblkhd", "The number of bytes in blocks currently allocated using mmap.", ) }); -pub static MALLINFO_FSMBLKS: LazyLock> = LazyLock::new(|| { +pub static MALLINFO_FSMBLKS: LazyLock> = LazyLock::new(|| { try_create_int_gauge( "mallinfo_fsmblks", "The total number of bytes in fastbin free blocks.", ) }); -pub static MALLINFO_UORDBLKS: LazyLock> = - LazyLock::new(|| { - try_create_int_gauge( - "mallinfo_uordblks", - "The total number of bytes used by in-use allocations.", - ) - }); -pub static MALLINFO_FORDBLKS: LazyLock> = - LazyLock::new(|| { - try_create_int_gauge( - "mallinfo_fordblks", - "The total number of bytes in free blocks.", - ) - }); -pub static MALLINFO_KEEPCOST: LazyLock> = - LazyLock::new(|| { - try_create_int_gauge( - "mallinfo_keepcost", - "The total amount of releasable free space at the top of the heap..", - ) - }); +pub static MALLINFO_UORDBLKS: LazyLock> = LazyLock::new(|| { + try_create_int_gauge( + "mallinfo_uordblks", + "The total number of bytes used by in-use allocations.", + ) +}); +pub static MALLINFO_FORDBLKS: LazyLock> = LazyLock::new(|| { + try_create_int_gauge( + "mallinfo_fordblks", + "The total number of bytes in free blocks.", + ) +}); +pub static MALLINFO_KEEPCOST: LazyLock> = LazyLock::new(|| { + try_create_int_gauge( + "mallinfo_keepcost", + "The total amount of releasable free space at the top of the heap..", + ) +}); /// Calls `mallinfo` and updates Prometheus metrics with the results. pub fn scrape_mallinfo_metrics() { diff --git a/common/malloc_utils/src/jemalloc.rs b/common/malloc_utils/src/jemalloc.rs index a392a74e8f1..0e2e00cb0ef 100644 --- a/common/malloc_utils/src/jemalloc.rs +++ b/common/malloc_utils/src/jemalloc.rs @@ -7,7 +7,7 @@ //! //! A) `JEMALLOC_SYS_WITH_MALLOC_CONF` at compile-time. //! B) `_RJEM_MALLOC_CONF` at runtime. -use lighthouse_metrics::{set_gauge, try_create_int_gauge, IntGauge}; +use metrics::{set_gauge, try_create_int_gauge, IntGauge}; use std::sync::LazyLock; use tikv_jemalloc_ctl::{arenas, epoch, stats, Error}; @@ -15,22 +15,22 @@ use tikv_jemalloc_ctl::{arenas, epoch, stats, Error}; static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; // Metrics for jemalloc. -pub static NUM_ARENAS: LazyLock> = +pub static NUM_ARENAS: LazyLock> = LazyLock::new(|| try_create_int_gauge("jemalloc_num_arenas", "The number of arenas in use")); -pub static BYTES_ALLOCATED: LazyLock> = LazyLock::new(|| { +pub static BYTES_ALLOCATED: LazyLock> = LazyLock::new(|| { try_create_int_gauge("jemalloc_bytes_allocated", "Equivalent to stats.allocated") }); -pub static BYTES_ACTIVE: LazyLock> = +pub static BYTES_ACTIVE: LazyLock> = LazyLock::new(|| try_create_int_gauge("jemalloc_bytes_active", "Equivalent to stats.active")); -pub static BYTES_MAPPED: LazyLock> = +pub static BYTES_MAPPED: LazyLock> = LazyLock::new(|| try_create_int_gauge("jemalloc_bytes_mapped", "Equivalent to stats.mapped")); -pub static BYTES_METADATA: LazyLock> = LazyLock::new(|| { +pub static BYTES_METADATA: LazyLock> = LazyLock::new(|| { try_create_int_gauge("jemalloc_bytes_metadata", "Equivalent to stats.metadata") }); -pub static BYTES_RESIDENT: LazyLock> = LazyLock::new(|| { +pub static BYTES_RESIDENT: LazyLock> = LazyLock::new(|| { try_create_int_gauge("jemalloc_bytes_resident", "Equivalent to stats.resident") }); -pub static BYTES_RETAINED: LazyLock> = LazyLock::new(|| { +pub static BYTES_RETAINED: LazyLock> = LazyLock::new(|| { try_create_int_gauge("jemalloc_bytes_retained", "Equivalent to stats.retained") }); diff --git a/common/metrics/Cargo.toml b/common/metrics/Cargo.toml new file mode 100644 index 00000000000..a7f4f4b967e --- /dev/null +++ b/common/metrics/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "metrics" +version = "0.2.0" +edition = { workspace = true } + +[dependencies] +prometheus = { workspace = true } diff --git a/common/lighthouse_metrics/src/lib.rs b/common/metrics/src/lib.rs similarity index 99% rename from common/lighthouse_metrics/src/lib.rs rename to common/metrics/src/lib.rs index 2a1e99defaf..1f2ac71aea5 100644 --- a/common/lighthouse_metrics/src/lib.rs +++ b/common/metrics/src/lib.rs @@ -20,10 +20,10 @@ //! ## Example //! //! ```rust -//! use lighthouse_metrics::*; +//! use metrics::*; //! use std::sync::LazyLock; //! -//! // These metrics are "magically" linked to the global registry defined in `lighthouse_metrics`. +//! // These metrics are "magically" linked to the global registry defined in `metrics`. //! pub static RUN_COUNT: LazyLock> = LazyLock::new(|| try_create_int_counter( //! "runs_total", //! "Total number of runs" diff --git a/common/monitoring_api/Cargo.toml b/common/monitoring_api/Cargo.toml index 55f18edd526..2da32c307ee 100644 --- a/common/monitoring_api/Cargo.toml +++ b/common/monitoring_api/Cargo.toml @@ -14,7 +14,7 @@ eth2 = { workspace = true } serde_json = { workspace = true } serde = { workspace = true } lighthouse_version = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } slog = { workspace = true } store = { workspace = true } regex = { workspace = true } diff --git a/common/monitoring_api/src/gather.rs b/common/monitoring_api/src/gather.rs index e157d82c11b..2f6c820f562 100644 --- a/common/monitoring_api/src/gather.rs +++ b/common/monitoring_api/src/gather.rs @@ -1,5 +1,5 @@ use super::types::{BeaconProcessMetrics, ValidatorProcessMetrics}; -use lighthouse_metrics::{MetricFamily, MetricType}; +use metrics::{MetricFamily, MetricType}; use serde_json::json; use std::collections::HashMap; use std::path::Path; @@ -155,7 +155,7 @@ fn get_value(mf: &MetricFamily) -> Option { /// Collects all metrics and returns a `serde_json::Value` object with the required metrics /// from the metrics hashmap. pub fn gather_metrics(metrics_map: &HashMap) -> Option { - let metric_families = lighthouse_metrics::gather(); + let metric_families = metrics::gather(); let mut res = serde_json::Map::with_capacity(metrics_map.len()); for mf in metric_families.iter() { let metric_name = mf.get_name(); diff --git a/common/slot_clock/Cargo.toml b/common/slot_clock/Cargo.toml index 13bcf006a9e..c2f330cd507 100644 --- a/common/slot_clock/Cargo.toml +++ b/common/slot_clock/Cargo.toml @@ -6,5 +6,5 @@ edition = { workspace = true } [dependencies] types = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } parking_lot = { workspace = true } diff --git a/common/slot_clock/src/metrics.rs b/common/slot_clock/src/metrics.rs index 24023c9ed75..ec95e90d4af 100644 --- a/common/slot_clock/src/metrics.rs +++ b/common/slot_clock/src/metrics.rs @@ -1,5 +1,5 @@ use crate::SlotClock; -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; use types::{EthSpec, Slot}; diff --git a/common/task_executor/Cargo.toml b/common/task_executor/Cargo.toml index 7928d4a3c97..26bcd7b339c 100644 --- a/common/task_executor/Cargo.toml +++ b/common/task_executor/Cargo.toml @@ -4,11 +4,17 @@ version = "0.1.0" authors = ["Sigma Prime "] edition = { workspace = true } +[features] +default = ["slog"] +slog = ["dep:slog", "dep:sloggers", "dep:logging"] +tracing = ["dep:tracing"] + [dependencies] async-channel = { workspace = true } -tokio = { workspace = true } -slog = { workspace = true } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } +slog = { workspace = true, optional = true } futures = { workspace = true } -lighthouse_metrics = { workspace = true } -sloggers = { workspace = true } -logging = { workspace = true } +metrics = { workspace = true } +sloggers = { workspace = true, optional = true } +logging = { workspace = true, optional = true } +tracing = { workspace = true, optional = true } diff --git a/common/task_executor/src/lib.rs b/common/task_executor/src/lib.rs index d6edfd3121c..92ddb7c0be2 100644 --- a/common/task_executor/src/lib.rs +++ b/common/task_executor/src/lib.rs @@ -1,14 +1,20 @@ mod metrics; +#[cfg(not(feature = "tracing"))] pub mod test_utils; use futures::channel::mpsc::Sender; use futures::prelude::*; -use slog::{debug, o, trace}; use std::sync::Weak; use tokio::runtime::{Handle, Runtime}; pub use tokio::task::JoinHandle; +// Set up logging framework +#[cfg(not(feature = "tracing"))] +use slog::{debug, o}; +#[cfg(feature = "tracing")] +use tracing::debug; + /// Provides a reason when Lighthouse is shut down. #[derive(Copy, Clone, Debug, PartialEq)] pub enum ShutdownReason { @@ -79,7 +85,7 @@ pub struct TaskExecutor { /// /// The task must provide a reason for shutting down. signal_tx: Sender, - + #[cfg(not(feature = "tracing"))] log: slog::Logger, } @@ -94,18 +100,20 @@ impl TaskExecutor { pub fn new>( handle: T, exit: async_channel::Receiver<()>, - log: slog::Logger, + #[cfg(not(feature = "tracing"))] log: slog::Logger, signal_tx: Sender, ) -> Self { Self { handle_provider: handle.into(), exit, signal_tx, + #[cfg(not(feature = "tracing"))] log, } } /// Clones the task executor adding a service name. + #[cfg(not(feature = "tracing"))] pub fn clone_with_name(&self, service_name: String) -> Self { TaskExecutor { handle_provider: self.handle_provider.clone(), @@ -115,6 +123,16 @@ impl TaskExecutor { } } + /// Clones the task executor adding a service name. + #[cfg(feature = "tracing")] + pub fn clone(&self) -> Self { + TaskExecutor { + handle_provider: self.handle_provider.clone(), + exit: self.exit.clone(), + signal_tx: self.signal_tx.clone(), + } + } + /// A convenience wrapper for `Self::spawn` which ignores a `Result` as long as both `Ok`/`Err` /// are of type `()`. /// @@ -150,10 +168,13 @@ impl TaskExecutor { drop(timer); }); } else { + #[cfg(not(feature = "tracing"))] debug!( self.log, "Couldn't spawn monitor task. Runtime shutting down" - ) + ); + #[cfg(feature = "tracing")] + debug!("Couldn't spawn monitor task. Runtime shutting down"); } } @@ -175,7 +196,7 @@ impl TaskExecutor { /// Spawn a future on the tokio runtime. This function does not wrap the task in an `async-channel::Receiver` /// like [spawn](#method.spawn). /// The caller of this function is responsible for wrapping up the task with an `async-channel::Receiver` to - /// ensure that the task gets canceled appropriately. + /// ensure that the task gets cancelled appropriately. /// This function generates prometheus metrics on number of tasks and task duration. /// /// This is useful in cases where the future to be spawned needs to do additional cleanup work when @@ -197,7 +218,10 @@ impl TaskExecutor { if let Some(handle) = self.handle() { handle.spawn(future); } else { + #[cfg(not(feature = "tracing"))] debug!(self.log, "Couldn't spawn task. Runtime shutting down"); + #[cfg(feature = "tracing")] + debug!("Couldn't spawn task. Runtime shutting down"); } } } @@ -215,7 +239,7 @@ impl TaskExecutor { /// Spawn a future on the tokio runtime wrapped in an `async-channel::Receiver` returning an optional /// join handle to the future. - /// The task is canceled when the corresponding async-channel is dropped. + /// The task is cancelled when the corresponding async-channel is dropped. /// /// This function generates prometheus metrics on number of tasks and task duration. pub fn spawn_handle( @@ -224,6 +248,8 @@ impl TaskExecutor { name: &'static str, ) -> Option>> { let exit = self.exit(); + + #[cfg(not(feature = "tracing"))] let log = self.log.clone(); if let Some(int_gauge) = metrics::get_int_gauge(&metrics::ASYNC_TASKS_COUNT, &[name]) { @@ -234,12 +260,12 @@ impl TaskExecutor { Some(handle.spawn(async move { futures::pin_mut!(exit); let result = match future::select(Box::pin(task), exit).await { - future::Either::Left((value, _)) => { - trace!(log, "Async task completed"; "task" => name); - Some(value) - } + future::Either::Left((value, _)) => Some(value), future::Either::Right(_) => { + #[cfg(not(feature = "tracing"))] debug!(log, "Async task shutdown, exit received"; "task" => name); + #[cfg(feature = "tracing")] + debug!(task = name, "Async task shutdown, exit received"); None } }; @@ -247,7 +273,10 @@ impl TaskExecutor { result })) } else { - debug!(self.log, "Couldn't spawn task. Runtime shutting down"); + #[cfg(not(feature = "tracing"))] + debug!(log, "Couldn't spawn task. Runtime shutting down"); + #[cfg(feature = "tracing")] + debug!("Couldn't spawn task. Runtime shutting down"); None } } else { @@ -270,6 +299,7 @@ impl TaskExecutor { F: FnOnce() -> R + Send + 'static, R: Send + 'static, { + #[cfg(not(feature = "tracing"))] let log = self.log.clone(); let timer = metrics::start_timer_vec(&metrics::BLOCKING_TASKS_HISTOGRAM, &[name]); @@ -278,19 +308,22 @@ impl TaskExecutor { let join_handle = if let Some(handle) = self.handle() { handle.spawn_blocking(task) } else { + #[cfg(not(feature = "tracing"))] debug!(self.log, "Couldn't spawn task. Runtime shutting down"); + #[cfg(feature = "tracing")] + debug!("Couldn't spawn task. Runtime shutting down"); return None; }; let future = async move { let result = match join_handle.await { - Ok(result) => { - trace!(log, "Blocking task completed"; "task" => name); - Ok(result) - } - Err(e) => { - debug!(log, "Blocking task ended unexpectedly"; "error" => %e); - Err(e) + Ok(result) => Ok(result), + Err(error) => { + #[cfg(not(feature = "tracing"))] + debug!(log, "Blocking task ended unexpectedly"; "error" => %error); + #[cfg(feature = "tracing")] + debug!(%error, "Blocking task ended unexpectedly"); + Err(error) } }; drop(timer); @@ -321,32 +354,48 @@ impl TaskExecutor { ) -> Option { let timer = metrics::start_timer_vec(&metrics::BLOCK_ON_TASKS_HISTOGRAM, &[name]); metrics::inc_gauge_vec(&metrics::BLOCK_ON_TASKS_COUNT, &[name]); + #[cfg(not(feature = "tracing"))] let log = self.log.clone(); let handle = self.handle()?; let exit = self.exit(); - + #[cfg(not(feature = "tracing"))] debug!( log, "Starting block_on task"; "name" => name ); + #[cfg(feature = "tracing")] + debug!(name, "Starting block_on task"); + handle.block_on(async { let output = tokio::select! { output = future => { + #[cfg(not(feature = "tracing"))] debug!( log, "Completed block_on task"; "name" => name ); + #[cfg(feature = "tracing")] + debug!( + name, + "Completed block_on task" + ); Some(output) }, _ = exit => { + #[cfg(not(feature = "tracing"))] debug!( log, "Cancelled block_on task"; "name" => name, ); + #[cfg(feature = "tracing")] + debug!( + name, + "Cancelled block_on task" + ); None } }; @@ -376,6 +425,7 @@ impl TaskExecutor { } /// Returns a reference to the logger. + #[cfg(not(feature = "tracing"))] pub fn log(&self) -> &slog::Logger { &self.log } diff --git a/common/task_executor/src/metrics.rs b/common/task_executor/src/metrics.rs index a40bfdf4e72..bd4d6a50b9e 100644 --- a/common/task_executor/src/metrics.rs +++ b/common/task_executor/src/metrics.rs @@ -1,5 +1,5 @@ /// Handles async task metrics -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; pub static ASYNC_TASKS_COUNT: LazyLock> = LazyLock::new(|| { diff --git a/common/warp_utils/Cargo.toml b/common/warp_utils/Cargo.toml index 84f5ce5f189..a9407c392d9 100644 --- a/common/warp_utils/Cargo.toml +++ b/common/warp_utils/Cargo.toml @@ -17,6 +17,6 @@ serde = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true } headers = "0.3.2" -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } serde_array_query = "0.1.0" bytes = { workspace = true } diff --git a/common/warp_utils/src/metrics.rs b/common/warp_utils/src/metrics.rs index 505d2775833..fabcf936507 100644 --- a/common/warp_utils/src/metrics.rs +++ b/common/warp_utils/src/metrics.rs @@ -1,5 +1,5 @@ use eth2::lighthouse::{ProcessHealth, SystemHealth}; -use lighthouse_metrics::*; +use metrics::*; use std::sync::LazyLock; pub static PROCESS_NUM_THREADS: LazyLock> = LazyLock::new(|| { diff --git a/consensus/fork_choice/Cargo.toml b/consensus/fork_choice/Cargo.toml index 4a4f6e9086a..b32e0aa6656 100644 --- a/consensus/fork_choice/Cargo.toml +++ b/consensus/fork_choice/Cargo.toml @@ -12,7 +12,7 @@ state_processing = { workspace = true } proto_array = { workspace = true } ethereum_ssz = { workspace = true } ethereum_ssz_derive = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } slog = { workspace = true } [dev-dependencies] diff --git a/consensus/fork_choice/src/metrics.rs b/consensus/fork_choice/src/metrics.rs index eb0dbf435e3..b5cda2f5871 100644 --- a/consensus/fork_choice/src/metrics.rs +++ b/consensus/fork_choice/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; use types::EthSpec; diff --git a/consensus/state_processing/Cargo.toml b/consensus/state_processing/Cargo.toml index 7b7c6eb0c48..b7f6ef7b2a9 100644 --- a/consensus/state_processing/Cargo.toml +++ b/consensus/state_processing/Cargo.toml @@ -25,7 +25,7 @@ ethereum_hashing = { workspace = true } int_to_bytes = { workspace = true } smallvec = { workspace = true } arbitrary = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } derivative = { workspace = true } test_random_derive = { path = "../../common/test_random_derive" } rand = { workspace = true } diff --git a/consensus/state_processing/src/common/update_progressive_balances_cache.rs b/consensus/state_processing/src/common/update_progressive_balances_cache.rs index af843b3acbc..101e8616835 100644 --- a/consensus/state_processing/src/common/update_progressive_balances_cache.rs +++ b/consensus/state_processing/src/common/update_progressive_balances_cache.rs @@ -4,7 +4,7 @@ use crate::metrics::{ PARTICIPATION_PREV_EPOCH_TARGET_ATTESTING_GWEI_PROGRESSIVE_TOTAL, }; use crate::{BlockProcessingError, EpochProcessingError}; -use lighthouse_metrics::set_gauge; +use metrics::set_gauge; use types::{ is_progressive_balances_enabled, BeaconState, BeaconStateError, ChainSpec, Epoch, EpochTotalBalances, EthSpec, ParticipationFlags, ProgressiveBalancesCache, Validator, diff --git a/consensus/state_processing/src/metrics.rs b/consensus/state_processing/src/metrics.rs index e6fe483776f..b53dee96d93 100644 --- a/consensus/state_processing/src/metrics.rs +++ b/consensus/state_processing/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; /* diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 7c37aa6d67d..1125697c7ca 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -49,7 +49,7 @@ clap_utils = { workspace = true } eth2_network_config = { workspace = true } lighthouse_version = { workspace = true } account_utils = { workspace = true } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } serde_yaml = { workspace = true } diff --git a/lighthouse/src/metrics.rs b/lighthouse/src/metrics.rs index 0002b43e7b9..30e0120582a 100644 --- a/lighthouse/src/metrics.rs +++ b/lighthouse/src/metrics.rs @@ -1,5 +1,5 @@ -pub use lighthouse_metrics::*; use lighthouse_version::VERSION; +pub use metrics::*; use slog::{error, Logger}; use std::sync::LazyLock; use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/slasher/Cargo.toml b/slasher/Cargo.toml index 034a1b71a3d..56a023df0bb 100644 --- a/slasher/Cargo.toml +++ b/slasher/Cargo.toml @@ -18,7 +18,7 @@ derivative = { workspace = true } ethereum_ssz = { workspace = true } ethereum_ssz_derive = { workspace = true } flate2 = { version = "1.0.14", features = ["zlib"], default-features = false } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } filesystem = { workspace = true } lru = { workspace = true } parking_lot = { workspace = true } diff --git a/slasher/src/metrics.rs b/slasher/src/metrics.rs index 2e49bd4aeba..cfeec2d74ed 100644 --- a/slasher/src/metrics.rs +++ b/slasher/src/metrics.rs @@ -1,4 +1,4 @@ -pub use lighthouse_metrics::*; +pub use metrics::*; use std::sync::LazyLock; pub static SLASHER_DATABASE_SIZE: LazyLock> = LazyLock::new(|| { diff --git a/validator_client/Cargo.toml b/validator_client/Cargo.toml index 4c338e91b9d..86825a9ee3b 100644 --- a/validator_client/Cargo.toml +++ b/validator_client/Cargo.toml @@ -48,7 +48,7 @@ ethereum_serde_utils = { workspace = true } libsecp256k1 = { workspace = true } ring = { workspace = true } rand = { workspace = true, features = ["small_rng"] } -lighthouse_metrics = { workspace = true } +metrics = { workspace = true } monitoring_api = { workspace = true } sensitive_url = { workspace = true } task_executor = { workspace = true } diff --git a/validator_client/src/http_metrics/metrics.rs b/validator_client/src/http_metrics/metrics.rs index 8bc569c67a2..57e1080fd9b 100644 --- a/validator_client/src/http_metrics/metrics.rs +++ b/validator_client/src/http_metrics/metrics.rs @@ -38,7 +38,7 @@ pub const SUBSCRIPTIONS: &str = "subscriptions"; pub const LOCAL_KEYSTORE: &str = "local_keystore"; pub const WEB3SIGNER: &str = "web3signer"; -pub use lighthouse_metrics::*; +pub use metrics::*; pub static GENESIS_DISTANCE: LazyLock> = LazyLock::new(|| { try_create_int_gauge( @@ -316,9 +316,7 @@ pub fn gather_prometheus_metrics( warp_utils::metrics::scrape_health_metrics(); - encoder - .encode(&lighthouse_metrics::gather(), &mut buffer) - .unwrap(); + encoder.encode(&metrics::gather(), &mut buffer).unwrap(); String::from_utf8(buffer).map_err(|e| format!("Failed to encode prometheus info: {:?}", e)) } diff --git a/validator_client/src/initialized_validators.rs b/validator_client/src/initialized_validators.rs index c94115e5ec5..0ef9a6a13d0 100644 --- a/validator_client/src/initialized_validators.rs +++ b/validator_client/src/initialized_validators.rs @@ -16,8 +16,8 @@ use account_utils::{ ZeroizeString, }; use eth2_keystore::Keystore; -use lighthouse_metrics::set_gauge; use lockfile::{Lockfile, LockfileError}; +use metrics::set_gauge; use parking_lot::{MappedMutexGuard, Mutex, MutexGuard}; use reqwest::{Certificate, Client, Error as ReqwestError, Identity}; use slog::{debug, error, info, warn, Logger}; diff --git a/validator_client/src/lib.rs b/validator_client/src/lib.rs index 9a02ffdefb3..05ec1e53aa7 100644 --- a/validator_client/src/lib.rs +++ b/validator_client/src/lib.rs @@ -25,7 +25,7 @@ pub use beacon_node_health::BeaconNodeSyncDistanceTiers; pub use cli::cli_app; pub use config::Config; use initialized_validators::InitializedValidators; -use lighthouse_metrics::set_gauge; +use metrics::set_gauge; use monitoring_api::{MonitoringHttpClient, ProcessType}; use sensitive_url::SensitiveUrl; pub use slashing_protection::{SlashingDatabase, SLASHING_PROTECTION_FILENAME}; diff --git a/validator_client/src/notifier.rs b/validator_client/src/notifier.rs index 00d7b14de7c..cda13a5e63c 100644 --- a/validator_client/src/notifier.rs +++ b/validator_client/src/notifier.rs @@ -1,6 +1,6 @@ use crate::http_metrics; use crate::{DutiesService, ProductionValidatorClient}; -use lighthouse_metrics::set_gauge; +use metrics::set_gauge; use slog::{debug, error, info, Logger}; use slot_clock::SlotClock; use tokio::time::{sleep, Duration};