diff --git a/Cargo.lock b/Cargo.lock index a29883f..2e7fd22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -275,6 +275,29 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "aws-lc-rs" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fcc8f365936c834db5514fc45aee5b1202d677e6b40e48468aaaa8183ca8c7" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b1d86e7705efe1be1b569bab41d4fa1e14e220b60a160f78de2db687add079" +dependencies = [ + "bindgen 0.69.5", + "cc", + "cmake", + "dunce", + "fs_extra", +] + [[package]] name = "axum" version = "0.8.3" @@ -450,12 +473,15 @@ dependencies = [ "itertools 0.12.1", "lazy_static", "lazycell", + "log", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash 1.1.0", "shlex", "syn", + "which", ] [[package]] @@ -703,6 +729,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.3" @@ -769,6 +804,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -1012,7 +1057,7 @@ dependencies = [ "openapiv3", "paste", "percent-encoding", - "rustls", + "rustls 0.22.4", "rustls-pemfile", "schemars", "scopeguard", @@ -1029,7 +1074,7 @@ dependencies = [ "slog-term", "thiserror 2.0.12", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", "toml", "uuid", "version_check", @@ -1051,6 +1096,12 @@ dependencies = [ "syn", ] +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "dyn-clone" version = "1.0.19" @@ -1232,6 +1283,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.31" @@ -1480,6 +1537,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -1578,6 +1644,23 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls 0.23.28", + "rustls-native-certs", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.2", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.11" @@ -2202,13 +2285,14 @@ dependencies = [ [[package]] name = "metrics-exporter-prometheus" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df88858cd28baaaf2cfc894e37789ed4184be0e1351157aec7bf3c2266c793fd" +checksum = "989903b4c7abfa6827a8d1128ef42faf83f8969d429797c5431f236f2cae8b8b" dependencies = [ "base64 0.22.1", "http-body-util", "hyper", + "hyper-rustls", "hyper-util", "indexmap 2.9.0", "ipnet", @@ -2367,7 +2451,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "security-framework", + "security-framework 2.11.1", "security-framework-sys", "tempfile", ] @@ -2631,6 +2715,16 @@ dependencies = [ "zerocopy 0.8.24", ] +[[package]] +name = "prettyplease" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837b9e10d61f45f987d50808f83d1ee3d206c66acf650c3e4ae2e1f6ddedf55" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro2" version = "1.0.94" @@ -2969,11 +3063,37 @@ dependencies = [ "log", "ring", "rustls-pki-types", - "rustls-webpki", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] +[[package]] +name = "rustls" +version = "0.23.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7160e3e10bf4535308537f3c4e1641468cd0e485175d6163087c0393c7d46643" +dependencies = [ + "aws-lc-rs", + "once_cell", + "rustls-pki-types", + "rustls-webpki 0.103.3", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework 3.2.0", +] + [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -3000,6 +3120,18 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.103.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.20" @@ -3066,7 +3198,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" +dependencies = [ + "bitflags", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -3392,6 +3537,7 @@ dependencies = [ "links", "log", "metrics", + "metrics-exporter-prometheus 0.17.1", "rand 0.9.1", "schemars", "semver", @@ -3666,11 +3812,21 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls", + "rustls 0.22.4", "rustls-pki-types", "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls 0.23.28", + "tokio", +] + [[package]] name = "tokio-tungstenite" version = "0.26.2" @@ -3922,7 +4078,7 @@ dependencies = [ "log", "lsm-tree", "metrics", - "metrics-exporter-prometheus 0.17.0", + "metrics-exporter-prometheus 0.17.1", "schemars", "semver", "serde", @@ -4181,6 +4337,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.44", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/spacedust/Cargo.toml b/spacedust/Cargo.toml index 7342fbb..d30a08c 100644 --- a/spacedust/Cargo.toml +++ b/spacedust/Cargo.toml @@ -15,6 +15,7 @@ jetstream = { path = "../jetstream", features = ["metrics"] } links = { path = "../links" } log = "0.4.27" metrics = "0.24.2" +metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] } rand = "0.9.1" schemars = "0.8.22" semver = "1.0.26" diff --git a/spacedust/src/main.rs b/spacedust/src/main.rs index 0a6b3fc..17f26c6 100644 --- a/spacedust/src/main.rs +++ b/spacedust/src/main.rs @@ -2,6 +2,7 @@ use spacedust::consumer; use spacedust::server; use clap::Parser; +use metrics_exporter_prometheus::PrometheusBuilder; use tokio::sync::broadcast; use tokio_util::sync::CancellationToken; @@ -50,6 +51,10 @@ async fn main() -> Result<(), String> { let args = Args::parse(); + if let Err(e) = install_metrics_server() { + log::error!("failed to install metrics server: {e:?}"); + }; + let server_shutdown = shutdown.clone(); let serving = tokio::spawn(async move { server::serve(b, server_shutdown).await @@ -68,3 +73,24 @@ async fn main() -> Result<(), String> { Ok(()) } + +fn install_metrics_server() -> Result<(), metrics_exporter_prometheus::BuildError> { + log::info!("installing metrics server..."); + let host = [0, 0, 0, 0]; + let port = 8765; + PrometheusBuilder::new() + .set_quantiles(&[0.5, 0.9, 0.99, 1.0])? + .set_bucket_duration(std::time::Duration::from_secs(60))? + .set_bucket_count(std::num::NonZero::new(10).unwrap()) // count * duration = 10 mins. stuff doesn't happen that fast here. + .set_enable_unit_suffix(false) // this seemed buggy for constellation (sometimes wouldn't engage) + .with_http_listener((host, port)) + .install()?; + log::info!( + "metrics server installed! listening on http://{}.{}.{}.{}:{port}", + host[0], + host[1], + host[2], + host[3] + ); + Ok(()) +}