lightweight com.atproto.sync.listReposByCollection
45
fork

Configure Feed

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

shuffle metrics setup

phil 9df10eb0 ef346d8e

+39 -34
+39 -34
src/main.rs
··· 49 49 50 50 /// TCP address for the Prometheus metrics HTTP endpoint. 51 51 /// If not set, metrics are not exported. 52 - #[arg(long, env = "LIGHTRAIL_METRICS_BIND")] 52 + #[arg(long, env = "LIGHTRAIL_METRICS_BIND", num_args = 0..=1, default_missing_value = "0.0.0.0:6789")] 53 53 metrics_bind: Option<SocketAddr>, 54 54 55 55 /// Log an error when a commit claims a collection birth but the index ··· 88 88 )); 89 89 90 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"); 91 + install_metrics(addr)?; 124 92 } 125 93 126 94 let db = storage::open(&args.db_path)?; ··· 197 165 Err(e) => Some(Error::TaskPanic(e)), 198 166 } 199 167 } 168 + 169 + fn install_metrics(addr: SocketAddr) -> Result<()> { 170 + use metrics_exporter_prometheus::Matcher; 171 + metrics_exporter_prometheus::PrometheusBuilder::new() 172 + .with_http_listener(addr) 173 + // CAR payload size in bytes: 1 KB → 4 MB 174 + .set_buckets_for_metric( 175 + Matcher::Full("lightrail_commit_car_bytes".to_string()), 176 + &[ 177 + 1_024.0, 178 + 4_096.0, 179 + 16_384.0, 180 + 65_536.0, 181 + 262_144.0, 182 + 1_048_576.0, 183 + 4_194_304.0, 184 + ], 185 + ) 186 + // Ops per commit: small commits dominate, occasional large batches 187 + .and_then(|b| { 188 + b.set_buckets_for_metric( 189 + Matcher::Full("lightrail_commit_ops".to_string()), 190 + &[1.0, 2.0, 5.0, 10.0, 25.0, 50.0, 100.0, 200.0], 191 + ) 192 + }) 193 + // Retry delay seconds: matches the backoff_secs() ladder exactly 194 + .and_then(|b| { 195 + b.set_buckets_for_metric( 196 + Matcher::Full("lightrail_resync_retry_delay_seconds".to_string()), 197 + &[60.0, 120.0, 240.0, 480.0, 960.0, 1_920.0, 3_600.0], 198 + ) 199 + }) 200 + .and_then(|b| b.install()) 201 + .map_err(|e| Error::Other(format!("failed to install metrics exporter: {e}")))?; 202 + info!(%addr, "metrics exporter listening"); 203 + Ok(()) 204 + }