Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

serve metrics

Changed files
+204 -9
spacedust
+177 -9
Cargo.lock
··· 276 276 checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 277 277 278 278 [[package]] 279 + name = "aws-lc-rs" 280 + version = "1.13.1" 281 + source = "registry+https://github.com/rust-lang/crates.io-index" 282 + checksum = "93fcc8f365936c834db5514fc45aee5b1202d677e6b40e48468aaaa8183ca8c7" 283 + dependencies = [ 284 + "aws-lc-sys", 285 + "zeroize", 286 + ] 287 + 288 + [[package]] 289 + name = "aws-lc-sys" 290 + version = "0.29.0" 291 + source = "registry+https://github.com/rust-lang/crates.io-index" 292 + checksum = "61b1d86e7705efe1be1b569bab41d4fa1e14e220b60a160f78de2db687add079" 293 + dependencies = [ 294 + "bindgen 0.69.5", 295 + "cc", 296 + "cmake", 297 + "dunce", 298 + "fs_extra", 299 + ] 300 + 301 + [[package]] 279 302 name = "axum" 280 303 version = "0.8.3" 281 304 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 450 473 "itertools 0.12.1", 451 474 "lazy_static", 452 475 "lazycell", 476 + "log", 477 + "prettyplease", 453 478 "proc-macro2", 454 479 "quote", 455 480 "regex", 456 481 "rustc-hash 1.1.0", 457 482 "shlex", 458 483 "syn", 484 + "which", 459 485 ] 460 486 461 487 [[package]] ··· 704 730 ] 705 731 706 732 [[package]] 733 + name = "cmake" 734 + version = "0.1.54" 735 + source = "registry+https://github.com/rust-lang/crates.io-index" 736 + checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" 737 + dependencies = [ 738 + "cc", 739 + ] 740 + 741 + [[package]] 707 742 name = "colorchoice" 708 743 version = "1.0.3" 709 744 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 770 805 ] 771 806 772 807 [[package]] 808 + name = "core-foundation" 809 + version = "0.10.1" 810 + source = "registry+https://github.com/rust-lang/crates.io-index" 811 + checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" 812 + dependencies = [ 813 + "core-foundation-sys", 814 + "libc", 815 + ] 816 + 817 + [[package]] 773 818 name = "core-foundation-sys" 774 819 version = "0.8.7" 775 820 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1012 1057 "openapiv3", 1013 1058 "paste", 1014 1059 "percent-encoding", 1015 - "rustls", 1060 + "rustls 0.22.4", 1016 1061 "rustls-pemfile", 1017 1062 "schemars", 1018 1063 "scopeguard", ··· 1029 1074 "slog-term", 1030 1075 "thiserror 2.0.12", 1031 1076 "tokio", 1032 - "tokio-rustls", 1077 + "tokio-rustls 0.25.0", 1033 1078 "toml", 1034 1079 "uuid", 1035 1080 "version_check", ··· 1050 1095 "serde_tokenstream", 1051 1096 "syn", 1052 1097 ] 1098 + 1099 + [[package]] 1100 + name = "dunce" 1101 + version = "1.0.5" 1102 + source = "registry+https://github.com/rust-lang/crates.io-index" 1103 + checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" 1053 1104 1054 1105 [[package]] 1055 1106 name = "dyn-clone" ··· 1231 1282 "rustix 0.38.44", 1232 1283 "windows-sys 0.52.0", 1233 1284 ] 1285 + 1286 + [[package]] 1287 + name = "fs_extra" 1288 + version = "1.3.0" 1289 + source = "registry+https://github.com/rust-lang/crates.io-index" 1290 + checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" 1234 1291 1235 1292 [[package]] 1236 1293 name = "futures" ··· 1479 1536 version = "0.4.3" 1480 1537 source = "registry+https://github.com/rust-lang/crates.io-index" 1481 1538 checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 1539 + 1540 + [[package]] 1541 + name = "home" 1542 + version = "0.5.11" 1543 + source = "registry+https://github.com/rust-lang/crates.io-index" 1544 + checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" 1545 + dependencies = [ 1546 + "windows-sys 0.59.0", 1547 + ] 1482 1548 1483 1549 [[package]] 1484 1550 name = "hostname" ··· 1579 1645 ] 1580 1646 1581 1647 [[package]] 1648 + name = "hyper-rustls" 1649 + version = "0.27.7" 1650 + source = "registry+https://github.com/rust-lang/crates.io-index" 1651 + checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" 1652 + dependencies = [ 1653 + "http", 1654 + "hyper", 1655 + "hyper-util", 1656 + "rustls 0.23.28", 1657 + "rustls-native-certs", 1658 + "rustls-pki-types", 1659 + "tokio", 1660 + "tokio-rustls 0.26.2", 1661 + "tower-service", 1662 + ] 1663 + 1664 + [[package]] 1582 1665 name = "hyper-util" 1583 1666 version = "0.1.11" 1584 1667 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2202 2285 2203 2286 [[package]] 2204 2287 name = "metrics-exporter-prometheus" 2205 - version = "0.17.0" 2288 + version = "0.17.1" 2206 2289 source = "registry+https://github.com/rust-lang/crates.io-index" 2207 - checksum = "df88858cd28baaaf2cfc894e37789ed4184be0e1351157aec7bf3c2266c793fd" 2290 + checksum = "989903b4c7abfa6827a8d1128ef42faf83f8969d429797c5431f236f2cae8b8b" 2208 2291 dependencies = [ 2209 2292 "base64 0.22.1", 2210 2293 "http-body-util", 2211 2294 "hyper", 2295 + "hyper-rustls", 2212 2296 "hyper-util", 2213 2297 "indexmap 2.9.0", 2214 2298 "ipnet", ··· 2367 2451 "openssl-probe", 2368 2452 "openssl-sys", 2369 2453 "schannel", 2370 - "security-framework", 2454 + "security-framework 2.11.1", 2371 2455 "security-framework-sys", 2372 2456 "tempfile", 2373 2457 ] ··· 2629 2713 checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" 2630 2714 dependencies = [ 2631 2715 "zerocopy 0.8.24", 2716 + ] 2717 + 2718 + [[package]] 2719 + name = "prettyplease" 2720 + version = "0.2.34" 2721 + source = "registry+https://github.com/rust-lang/crates.io-index" 2722 + checksum = "6837b9e10d61f45f987d50808f83d1ee3d206c66acf650c3e4ae2e1f6ddedf55" 2723 + dependencies = [ 2724 + "proc-macro2", 2725 + "syn", 2632 2726 ] 2633 2727 2634 2728 [[package]] ··· 2969 3063 "log", 2970 3064 "ring", 2971 3065 "rustls-pki-types", 2972 - "rustls-webpki", 3066 + "rustls-webpki 0.102.8", 2973 3067 "subtle", 2974 3068 "zeroize", 2975 3069 ] 2976 3070 2977 3071 [[package]] 3072 + name = "rustls" 3073 + version = "0.23.28" 3074 + source = "registry+https://github.com/rust-lang/crates.io-index" 3075 + checksum = "7160e3e10bf4535308537f3c4e1641468cd0e485175d6163087c0393c7d46643" 3076 + dependencies = [ 3077 + "aws-lc-rs", 3078 + "once_cell", 3079 + "rustls-pki-types", 3080 + "rustls-webpki 0.103.3", 3081 + "subtle", 3082 + "zeroize", 3083 + ] 3084 + 3085 + [[package]] 3086 + name = "rustls-native-certs" 3087 + version = "0.8.1" 3088 + source = "registry+https://github.com/rust-lang/crates.io-index" 3089 + checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" 3090 + dependencies = [ 3091 + "openssl-probe", 3092 + "rustls-pki-types", 3093 + "schannel", 3094 + "security-framework 3.2.0", 3095 + ] 3096 + 3097 + [[package]] 2978 3098 name = "rustls-pemfile" 2979 3099 version = "2.2.0" 2980 3100 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3001 3121 ] 3002 3122 3003 3123 [[package]] 3124 + name = "rustls-webpki" 3125 + version = "0.103.3" 3126 + source = "registry+https://github.com/rust-lang/crates.io-index" 3127 + checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" 3128 + dependencies = [ 3129 + "aws-lc-rs", 3130 + "ring", 3131 + "rustls-pki-types", 3132 + "untrusted", 3133 + ] 3134 + 3135 + [[package]] 3004 3136 name = "rustversion" 3005 3137 version = "1.0.20" 3006 3138 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3066 3198 checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" 3067 3199 dependencies = [ 3068 3200 "bitflags", 3069 - "core-foundation", 3201 + "core-foundation 0.9.4", 3202 + "core-foundation-sys", 3203 + "libc", 3204 + "security-framework-sys", 3205 + ] 3206 + 3207 + [[package]] 3208 + name = "security-framework" 3209 + version = "3.2.0" 3210 + source = "registry+https://github.com/rust-lang/crates.io-index" 3211 + checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" 3212 + dependencies = [ 3213 + "bitflags", 3214 + "core-foundation 0.10.1", 3070 3215 "core-foundation-sys", 3071 3216 "libc", 3072 3217 "security-framework-sys", ··· 3392 3537 "links", 3393 3538 "log", 3394 3539 "metrics", 3540 + "metrics-exporter-prometheus 0.17.1", 3395 3541 "rand 0.9.1", 3396 3542 "schemars", 3397 3543 "semver", ··· 3666 3812 source = "registry+https://github.com/rust-lang/crates.io-index" 3667 3813 checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" 3668 3814 dependencies = [ 3669 - "rustls", 3815 + "rustls 0.22.4", 3670 3816 "rustls-pki-types", 3671 3817 "tokio", 3672 3818 ] 3673 3819 3674 3820 [[package]] 3821 + name = "tokio-rustls" 3822 + version = "0.26.2" 3823 + source = "registry+https://github.com/rust-lang/crates.io-index" 3824 + checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" 3825 + dependencies = [ 3826 + "rustls 0.23.28", 3827 + "tokio", 3828 + ] 3829 + 3830 + [[package]] 3675 3831 name = "tokio-tungstenite" 3676 3832 version = "0.26.2" 3677 3833 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3922 4078 "log", 3923 4079 "lsm-tree", 3924 4080 "metrics", 3925 - "metrics-exporter-prometheus 0.17.0", 4081 + "metrics-exporter-prometheus 0.17.1", 3926 4082 "schemars", 3927 4083 "semver", 3928 4084 "serde", ··· 4179 4335 dependencies = [ 4180 4336 "js-sys", 4181 4337 "wasm-bindgen", 4338 + ] 4339 + 4340 + [[package]] 4341 + name = "which" 4342 + version = "4.4.2" 4343 + source = "registry+https://github.com/rust-lang/crates.io-index" 4344 + checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" 4345 + dependencies = [ 4346 + "either", 4347 + "home", 4348 + "once_cell", 4349 + "rustix 0.38.44", 4182 4350 ] 4183 4351 4184 4352 [[package]]
+1
spacedust/Cargo.toml
··· 15 15 links = { path = "../links" } 16 16 log = "0.4.27" 17 17 metrics = "0.24.2" 18 + metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] } 18 19 rand = "0.9.1" 19 20 schemars = "0.8.22" 20 21 semver = "1.0.26"
+26
spacedust/src/main.rs
··· 2 2 use spacedust::server; 3 3 4 4 use clap::Parser; 5 + use metrics_exporter_prometheus::PrometheusBuilder; 5 6 use tokio::sync::broadcast; 6 7 use tokio_util::sync::CancellationToken; 7 8 ··· 50 51 51 52 let args = Args::parse(); 52 53 54 + if let Err(e) = install_metrics_server() { 55 + log::error!("failed to install metrics server: {e:?}"); 56 + }; 57 + 53 58 let server_shutdown = shutdown.clone(); 54 59 let serving = tokio::spawn(async move { 55 60 server::serve(b, server_shutdown).await ··· 68 73 69 74 Ok(()) 70 75 } 76 + 77 + fn install_metrics_server() -> Result<(), metrics_exporter_prometheus::BuildError> { 78 + log::info!("installing metrics server..."); 79 + let host = [0, 0, 0, 0]; 80 + let port = 8765; 81 + PrometheusBuilder::new() 82 + .set_quantiles(&[0.5, 0.9, 0.99, 1.0])? 83 + .set_bucket_duration(std::time::Duration::from_secs(60))? 84 + .set_bucket_count(std::num::NonZero::new(10).unwrap()) // count * duration = 10 mins. stuff doesn't happen that fast here. 85 + .set_enable_unit_suffix(false) // this seemed buggy for constellation (sometimes wouldn't engage) 86 + .with_http_listener((host, port)) 87 + .install()?; 88 + log::info!( 89 + "metrics server installed! listening on http://{}.{}.{}.{}:{port}", 90 + host[0], 91 + host[1], 92 + host[2], 93 + host[3] 94 + ); 95 + Ok(()) 96 + }