etl_core/metrics/
names.rs1pub const L_PIPELINE: &str = "pipeline";
13pub const L_COMPONENT: &str = "component";
15pub const L_COMPONENT_TYPE: &str = "component_type";
17
18pub const L_PARTITION: &str = "partition";
22pub const L_SHARD: &str = "shard";
24pub const L_REPLICA: &str = "replica";
26pub const L_REASON: &str = "reason";
28pub const L_OUTCOME: &str = "outcome";
30pub const L_EVENT: &str = "event";
32pub const L_ERROR_TYPE: &str = "error_type";
34pub const L_QUEUE: &str = "queue";
36pub const L_STATE: &str = "state";
38pub const L_VERSION: &str = "version";
40
41pub const SOURCE_RECORDS_TOTAL: &str = "etl_source_records_total";
45pub const SOURCE_BYTES_TOTAL: &str = "etl_source_bytes_total";
47pub const SOURCE_POLL_DURATION_SECONDS: &str = "etl_source_poll_duration_seconds";
49pub const SOURCE_LAG_RECORDS: &str = "etl_source_lag_records";
51pub const SOURCE_REBALANCES_TOTAL: &str = "etl_source_rebalances_total";
53pub const SOURCE_LANES_ACTIVE: &str = "etl_source_lanes_active";
55
56pub const DESER_RECORDS_TOTAL: &str = "etl_deser_records_total";
61pub const DESER_RECORDS_DROPPED_TOTAL: &str = "etl_deser_records_dropped_total";
63pub const DESER_BATCH_DURATION_SECONDS: &str = "etl_deser_batch_duration_seconds";
65pub const DESER_NOT_READY_TOTAL: &str = "etl_deser_not_ready_total";
69
70pub const OPERATOR_RECORDS_IN_TOTAL: &str = "etl_operator_records_in_total";
74pub const OPERATOR_RECORDS_OUT_TOTAL: &str = "etl_operator_records_out_total";
76pub const OPERATOR_RECORDS_DROPPED_TOTAL: &str = "etl_operator_records_dropped_total";
78pub const OPERATOR_ERRORS_TOTAL: &str = "etl_operator_errors_total";
80pub const OPERATOR_BATCH_DURATION_SECONDS: &str = "etl_operator_batch_duration_seconds";
82
83pub const QUEUE_DEPTH: &str = "etl_queue_depth";
87pub const QUEUE_CAPACITY: &str = "etl_queue_capacity";
89pub const QUEUE_FULL_EVENTS_TOTAL: &str = "etl_queue_full_events_total";
91
92pub const BACKPRESSURE_PAUSED: &str = "etl_backpressure_paused";
96pub const BACKPRESSURE_PAUSED_SECONDS_TOTAL: &str = "etl_backpressure_paused_seconds_total";
99pub const BACKPRESSURE_PAUSE_EVENTS_TOTAL: &str = "etl_backpressure_pause_events_total";
101pub const BACKPRESSURE_INFLIGHT_BYTES: &str = "etl_backpressure_inflight_bytes";
103
104pub const SINK_RECORDS_TOTAL: &str = "etl_sink_records_total";
108pub const SINK_BYTES_TOTAL: &str = "etl_sink_bytes_total";
110pub const SINK_BATCH_ROWS: &str = "etl_sink_batch_rows";
112pub const SINK_BATCH_BYTES: &str = "etl_sink_batch_bytes";
114pub const SINK_FLUSHES_TOTAL: &str = "etl_sink_flushes_total";
116pub const SINK_FLUSH_DURATION_SECONDS: &str = "etl_sink_flush_duration_seconds";
118pub const SINK_RETRIES_TOTAL: &str = "etl_sink_retries_total";
120pub const SINK_ERRORS_TOTAL: &str = "etl_sink_errors_total";
122pub const SINK_INFLIGHT_BATCHES: &str = "etl_sink_inflight_batches";
124pub const SINK_REPLICA_HEALTHY: &str = "etl_sink_replica_healthy";
126pub const SINK_BREAKER_OPENS_TOTAL: &str = "etl_sink_breaker_opens_total";
128pub const SINK_ABANDONED_BATCHES_TOTAL: &str = "etl_sink_abandoned_batches_total";
130
131pub const CHECKPOINT_PENDING_BATCHES: &str = "etl_checkpoint_pending_batches";
136pub const CHECKPOINT_COMMITS_TOTAL: &str = "etl_checkpoint_commits_total";
138pub const CHECKPOINT_COMMIT_DURATION_SECONDS: &str = "etl_checkpoint_commit_duration_seconds";
140pub const CHECKPOINT_WATERMARK_AGE_SECONDS: &str = "etl_checkpoint_watermark_age_seconds";
143
144pub const E2E_LATENCY_SECONDS: &str = "etl_e2e_latency_seconds";
148
149pub const PIPELINE_INFO: &str = "etl_pipeline_info";
153pub const PIPELINE_STATE: &str = "etl_pipeline_state";
155pub const PIPELINE_THREADS: &str = "etl_pipeline_threads";
157
158pub const COUNTERS: &[&str] = &[
160 SOURCE_RECORDS_TOTAL,
161 SOURCE_BYTES_TOTAL,
162 SOURCE_REBALANCES_TOTAL,
163 DESER_RECORDS_TOTAL,
164 DESER_RECORDS_DROPPED_TOTAL,
165 DESER_NOT_READY_TOTAL,
166 OPERATOR_RECORDS_IN_TOTAL,
167 OPERATOR_RECORDS_OUT_TOTAL,
168 OPERATOR_RECORDS_DROPPED_TOTAL,
169 OPERATOR_ERRORS_TOTAL,
170 QUEUE_FULL_EVENTS_TOTAL,
171 BACKPRESSURE_PAUSE_EVENTS_TOTAL,
172 SINK_RECORDS_TOTAL,
173 SINK_BYTES_TOTAL,
174 SINK_FLUSHES_TOTAL,
175 SINK_RETRIES_TOTAL,
176 SINK_ERRORS_TOTAL,
177 SINK_BREAKER_OPENS_TOTAL,
178 SINK_ABANDONED_BATCHES_TOTAL,
179 CHECKPOINT_COMMITS_TOTAL,
180];
181
182pub const GAUGES: &[&str] = &[
184 SOURCE_LAG_RECORDS,
185 SOURCE_LANES_ACTIVE,
186 QUEUE_DEPTH,
187 QUEUE_CAPACITY,
188 BACKPRESSURE_PAUSED,
189 BACKPRESSURE_PAUSED_SECONDS_TOTAL,
190 BACKPRESSURE_INFLIGHT_BYTES,
191 SINK_INFLIGHT_BATCHES,
192 SINK_REPLICA_HEALTHY,
193 CHECKPOINT_PENDING_BATCHES,
194 CHECKPOINT_WATERMARK_AGE_SECONDS,
195 PIPELINE_INFO,
196 PIPELINE_STATE,
197 PIPELINE_THREADS,
198];
199
200pub const HISTOGRAMS: &[&str] = &[
202 SOURCE_POLL_DURATION_SECONDS,
203 DESER_BATCH_DURATION_SECONDS,
204 OPERATOR_BATCH_DURATION_SECONDS,
205 SINK_BATCH_ROWS,
206 SINK_BATCH_BYTES,
207 SINK_FLUSH_DURATION_SECONDS,
208 CHECKPOINT_COMMIT_DURATION_SECONDS,
209 E2E_LATENCY_SECONDS,
210];
211
212#[cfg(test)]
213mod tests {
214 use super::*;
215 use std::collections::HashSet;
216
217 #[test]
218 fn names_follow_prometheus_conventions() {
219 for name in COUNTERS {
220 assert!(
221 name.ends_with("_total"),
222 "counter `{name}` must end in _total"
223 );
224 }
225 for name in HISTOGRAMS {
226 assert!(
227 name.ends_with("_seconds") || name.ends_with("_rows") || name.ends_with("_bytes"),
228 "histogram `{name}` must carry a unit suffix"
229 );
230 }
231 for name in GAUGES {
232 if *name == BACKPRESSURE_PAUSED_SECONDS_TOTAL {
236 continue;
237 }
238 assert!(
239 !name.ends_with("_total"),
240 "gauge `{name}` must not end in _total"
241 );
242 }
243 }
244
245 #[test]
246 fn names_are_prefixed_and_unique() {
247 let all: Vec<&str> = COUNTERS
248 .iter()
249 .chain(GAUGES)
250 .chain(HISTOGRAMS)
251 .copied()
252 .collect();
253 let unique: HashSet<&str> = all.iter().copied().collect();
254 assert_eq!(unique.len(), all.len(), "duplicate metric name");
255 for name in &all {
256 assert!(name.starts_with("etl_"), "`{name}` must be etl_-prefixed");
257 }
258 }
259}