upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-01-12 09:52:36 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-01-12 09:52:36 +0000
commit93227ce02e484c1e727bfd07ceeb72fd95774170 (patch)
treed02c99355b083c4a30f2ae75f42eaaa70d213b24 /src/main.rs
parenta63dc8a9e5f9cad50f4ea7c6c5d2ed544bc70656 (diff)
fix(metrics): count repositories on disk on each metrics request
Implements ngit_repositories_total metric by counting *.git directories on disk every time /metrics is requested (~15s interval by Prometheus). This approach is simpler than increment-on-create because: - No need to pass metrics through the relay builder chain - Always accurate and self-correcting - Negligible performance impact (~100-200 dir entries) Changes: - Add count_repositories_on_disk() static method to Metrics - Update Metrics::render() to count repos before encoding metrics - Pass git_data_path to Metrics::new() in main.rs - Consolidate metrics tests to avoid global Prometheus registry conflicts Fixes repository count metric issue from Phase 8 deployment plan.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 44545b5..8b959a6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -40,9 +40,12 @@ async fn main() -> Result<()> {
40 // Initialize metrics if enabled 40 // Initialize metrics if enabled
41 let metrics = if config.metrics_enabled { 41 let metrics = if config.metrics_enabled {
42 info!("Metrics enabled on /metrics endpoint"); 42 info!("Metrics enabled on /metrics endpoint");
43 Some(Arc::new(Metrics::new( 43 let m = Arc::new(Metrics::new(
44 config.metrics_connection_per_ip_abuse_threshold, 44 config.metrics_connection_per_ip_abuse_threshold,
45 ))) 45 Some(config.effective_git_data_path()),
46 ));
47 info!("Repository count will be updated on each metrics request");
48 Some(m)
46 } else { 49 } else {
47 info!("Metrics disabled"); 50 info!("Metrics disabled");
48 None 51 None