tangled
alpha
login
or
join now
microcosm.blue
/
microcosm-rs
65
fork
atom
Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
65
fork
atom
overview
issues
8
pulls
2
pipelines
serve metrics
bad-example.com
8 months ago
8783986f
9d924ff7
+204
-9
3 changed files
expand all
collapse all
unified
split
Cargo.lock
spacedust
Cargo.toml
src
main.rs
+177
-9
Cargo.lock
···
276
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
277
278
[[package]]
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
279
name = "axum"
280
version = "0.8.3"
281
source = "registry+https://github.com/rust-lang/crates.io-index"
···
450
"itertools 0.12.1",
451
"lazy_static",
452
"lazycell",
0
0
453
"proc-macro2",
454
"quote",
455
"regex",
456
"rustc-hash 1.1.0",
457
"shlex",
458
"syn",
0
459
]
460
461
[[package]]
···
704
]
705
706
[[package]]
0
0
0
0
0
0
0
0
0
707
name = "colorchoice"
708
version = "1.0.3"
709
source = "registry+https://github.com/rust-lang/crates.io-index"
···
770
]
771
772
[[package]]
0
0
0
0
0
0
0
0
0
0
773
name = "core-foundation-sys"
774
version = "0.8.7"
775
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1012
"openapiv3",
1013
"paste",
1014
"percent-encoding",
1015
-
"rustls",
1016
"rustls-pemfile",
1017
"schemars",
1018
"scopeguard",
···
1029
"slog-term",
1030
"thiserror 2.0.12",
1031
"tokio",
1032
-
"tokio-rustls",
1033
"toml",
1034
"uuid",
1035
"version_check",
···
1050
"serde_tokenstream",
1051
"syn",
1052
]
0
0
0
0
0
0
1053
1054
[[package]]
1055
name = "dyn-clone"
···
1231
"rustix 0.38.44",
1232
"windows-sys 0.52.0",
1233
]
0
0
0
0
0
0
1234
1235
[[package]]
1236
name = "futures"
···
1479
version = "0.4.3"
1480
source = "registry+https://github.com/rust-lang/crates.io-index"
1481
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
0
0
0
0
0
0
0
0
0
1482
1483
[[package]]
1484
name = "hostname"
···
1579
]
1580
1581
[[package]]
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1582
name = "hyper-util"
1583
version = "0.1.11"
1584
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2202
2203
[[package]]
2204
name = "metrics-exporter-prometheus"
2205
-
version = "0.17.0"
2206
source = "registry+https://github.com/rust-lang/crates.io-index"
2207
-
checksum = "df88858cd28baaaf2cfc894e37789ed4184be0e1351157aec7bf3c2266c793fd"
2208
dependencies = [
2209
"base64 0.22.1",
2210
"http-body-util",
2211
"hyper",
0
2212
"hyper-util",
2213
"indexmap 2.9.0",
2214
"ipnet",
···
2367
"openssl-probe",
2368
"openssl-sys",
2369
"schannel",
2370
-
"security-framework",
2371
"security-framework-sys",
2372
"tempfile",
2373
]
···
2629
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
2630
dependencies = [
2631
"zerocopy 0.8.24",
0
0
0
0
0
0
0
0
0
0
2632
]
2633
2634
[[package]]
···
2969
"log",
2970
"ring",
2971
"rustls-pki-types",
2972
-
"rustls-webpki",
2973
"subtle",
2974
"zeroize",
2975
]
2976
2977
[[package]]
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2978
name = "rustls-pemfile"
2979
version = "2.2.0"
2980
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3001
]
3002
3003
[[package]]
0
0
0
0
0
0
0
0
0
0
0
0
3004
name = "rustversion"
3005
version = "1.0.20"
3006
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3066
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
3067
dependencies = [
3068
"bitflags",
3069
-
"core-foundation",
0
0
0
0
0
0
0
0
0
0
0
0
0
3070
"core-foundation-sys",
3071
"libc",
3072
"security-framework-sys",
···
3392
"links",
3393
"log",
3394
"metrics",
0
3395
"rand 0.9.1",
3396
"schemars",
3397
"semver",
···
3666
source = "registry+https://github.com/rust-lang/crates.io-index"
3667
checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
3668
dependencies = [
3669
-
"rustls",
3670
"rustls-pki-types",
3671
"tokio",
3672
]
3673
3674
[[package]]
0
0
0
0
0
0
0
0
0
0
3675
name = "tokio-tungstenite"
3676
version = "0.26.2"
3677
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3922
"log",
3923
"lsm-tree",
3924
"metrics",
3925
-
"metrics-exporter-prometheus 0.17.0",
3926
"schemars",
3927
"semver",
3928
"serde",
···
4179
dependencies = [
4180
"js-sys",
4181
"wasm-bindgen",
0
0
0
0
0
0
0
0
0
0
0
0
4182
]
4183
4184
[[package]]
···
276
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
277
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]]
302
name = "axum"
303
version = "0.8.3"
304
source = "registry+https://github.com/rust-lang/crates.io-index"
···
473
"itertools 0.12.1",
474
"lazy_static",
475
"lazycell",
476
+
"log",
477
+
"prettyplease",
478
"proc-macro2",
479
"quote",
480
"regex",
481
"rustc-hash 1.1.0",
482
"shlex",
483
"syn",
484
+
"which",
485
]
486
487
[[package]]
···
730
]
731
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]]
742
name = "colorchoice"
743
version = "1.0.3"
744
source = "registry+https://github.com/rust-lang/crates.io-index"
···
805
]
806
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]]
818
name = "core-foundation-sys"
819
version = "0.8.7"
820
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1057
"openapiv3",
1058
"paste",
1059
"percent-encoding",
1060
+
"rustls 0.22.4",
1061
"rustls-pemfile",
1062
"schemars",
1063
"scopeguard",
···
1074
"slog-term",
1075
"thiserror 2.0.12",
1076
"tokio",
1077
+
"tokio-rustls 0.25.0",
1078
"toml",
1079
"uuid",
1080
"version_check",
···
1095
"serde_tokenstream",
1096
"syn",
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"
1104
1105
[[package]]
1106
name = "dyn-clone"
···
1282
"rustix 0.38.44",
1283
"windows-sys 0.52.0",
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"
1291
1292
[[package]]
1293
name = "futures"
···
1536
version = "0.4.3"
1537
source = "registry+https://github.com/rust-lang/crates.io-index"
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
+
]
1548
1549
[[package]]
1550
name = "hostname"
···
1645
]
1646
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]]
1665
name = "hyper-util"
1666
version = "0.1.11"
1667
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2285
2286
[[package]]
2287
name = "metrics-exporter-prometheus"
2288
+
version = "0.17.1"
2289
source = "registry+https://github.com/rust-lang/crates.io-index"
2290
+
checksum = "989903b4c7abfa6827a8d1128ef42faf83f8969d429797c5431f236f2cae8b8b"
2291
dependencies = [
2292
"base64 0.22.1",
2293
"http-body-util",
2294
"hyper",
2295
+
"hyper-rustls",
2296
"hyper-util",
2297
"indexmap 2.9.0",
2298
"ipnet",
···
2451
"openssl-probe",
2452
"openssl-sys",
2453
"schannel",
2454
+
"security-framework 2.11.1",
2455
"security-framework-sys",
2456
"tempfile",
2457
]
···
2713
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
2714
dependencies = [
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",
2726
]
2727
2728
[[package]]
···
3063
"log",
3064
"ring",
3065
"rustls-pki-types",
3066
+
"rustls-webpki 0.102.8",
3067
"subtle",
3068
"zeroize",
3069
]
3070
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]]
3098
name = "rustls-pemfile"
3099
version = "2.2.0"
3100
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3121
]
3122
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]]
3136
name = "rustversion"
3137
version = "1.0.20"
3138
source = "registry+https://github.com/rust-lang/crates.io-index"
···
3198
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
3199
dependencies = [
3200
"bitflags",
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",
3215
"core-foundation-sys",
3216
"libc",
3217
"security-framework-sys",
···
3537
"links",
3538
"log",
3539
"metrics",
3540
+
"metrics-exporter-prometheus 0.17.1",
3541
"rand 0.9.1",
3542
"schemars",
3543
"semver",
···
3812
source = "registry+https://github.com/rust-lang/crates.io-index"
3813
checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
3814
dependencies = [
3815
+
"rustls 0.22.4",
3816
"rustls-pki-types",
3817
"tokio",
3818
]
3819
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]]
3831
name = "tokio-tungstenite"
3832
version = "0.26.2"
3833
source = "registry+https://github.com/rust-lang/crates.io-index"
···
4078
"log",
4079
"lsm-tree",
4080
"metrics",
4081
+
"metrics-exporter-prometheus 0.17.1",
4082
"schemars",
4083
"semver",
4084
"serde",
···
4335
dependencies = [
4336
"js-sys",
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",
4350
]
4351
4352
[[package]]
+1
spacedust/Cargo.toml
···
15
links = { path = "../links" }
16
log = "0.4.27"
17
metrics = "0.24.2"
0
18
rand = "0.9.1"
19
schemars = "0.8.22"
20
semver = "1.0.26"
···
15
links = { path = "../links" }
16
log = "0.4.27"
17
metrics = "0.24.2"
18
+
metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] }
19
rand = "0.9.1"
20
schemars = "0.8.22"
21
semver = "1.0.26"
+26
spacedust/src/main.rs
···
2
use spacedust::server;
3
4
use clap::Parser;
0
5
use tokio::sync::broadcast;
6
use tokio_util::sync::CancellationToken;
7
···
50
51
let args = Args::parse();
52
0
0
0
0
53
let server_shutdown = shutdown.clone();
54
let serving = tokio::spawn(async move {
55
server::serve(b, server_shutdown).await
···
68
69
Ok(())
70
}
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
2
use spacedust::server;
3
4
use clap::Parser;
5
+
use metrics_exporter_prometheus::PrometheusBuilder;
6
use tokio::sync::broadcast;
7
use tokio_util::sync::CancellationToken;
8
···
51
52
let args = Args::parse();
53
54
+
if let Err(e) = install_metrics_server() {
55
+
log::error!("failed to install metrics server: {e:?}");
56
+
};
57
+
58
let server_shutdown = shutdown.clone();
59
let serving = tokio::spawn(async move {
60
server::serve(b, server_shutdown).await
···
73
74
Ok(())
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
+
}