lightweight com.atproto.sync.listReposByCollection
45
fork

Configure Feed

Select the types of activity you want to include in your feed.

expose metrics

phil ef346d8e 2fa660af

+41
+41
src/main.rs
··· 47 47 #[arg(long, env = "LIGHTRAIL_IDENT_CACHE_SIZE", default_value_t = 1_000_000)] 48 48 ident_cache_size: u64, 49 49 50 + /// TCP address for the Prometheus metrics HTTP endpoint. 51 + /// If not set, metrics are not exported. 52 + #[arg(long, env = "LIGHTRAIL_METRICS_BIND")] 53 + metrics_bind: Option<SocketAddr>, 54 + 50 55 /// Log an error when a commit claims a collection birth but the index 51 56 /// already has that collection for the DID (temporary diagnostic flag). 52 57 #[arg(long, env = "LIGHTRAIL_VALIDATE_BIRTHS")] ··· 81 86 plc_url, 82 87 ident_cache_size, 83 88 )); 89 + 90 + if let Some(addr) = args.metrics_bind { 91 + use metrics_exporter_prometheus::Matcher; 92 + metrics_exporter_prometheus::PrometheusBuilder::new() 93 + .with_http_listener(addr) 94 + // CAR payload size in bytes: 1 KB → 4 MB 95 + .set_buckets_for_metric( 96 + Matcher::Full("lightrail_commit_car_bytes".to_string()), 97 + &[ 98 + 1_024.0, 99 + 4_096.0, 100 + 16_384.0, 101 + 65_536.0, 102 + 262_144.0, 103 + 1_048_576.0, 104 + 4_194_304.0, 105 + ], 106 + ) 107 + // Ops per commit: small commits dominate, occasional large batches 108 + .and_then(|b| { 109 + b.set_buckets_for_metric( 110 + Matcher::Full("lightrail_commit_ops".to_string()), 111 + &[1.0, 2.0, 5.0, 10.0, 25.0, 50.0, 100.0, 200.0], 112 + ) 113 + }) 114 + // Retry delay seconds: matches the backoff_secs() ladder exactly 115 + .and_then(|b| { 116 + b.set_buckets_for_metric( 117 + Matcher::Full("lightrail_resync_retry_delay_seconds".to_string()), 118 + &[60.0, 120.0, 240.0, 480.0, 960.0, 1_920.0, 3_600.0], 119 + ) 120 + }) 121 + .and_then(|b| b.install()) 122 + .map_err(|e| Error::Other(format!("failed to install metrics exporter: {e}")))?; 123 + info!(%addr, "metrics exporter listening"); 124 + } 84 125 85 126 let db = storage::open(&args.db_path)?; 86 127 let token = CancellationToken::new();