sui_analytics_indexer/
metrics.rs1use prometheus::HistogramOpts;
5use prometheus::HistogramVec;
6use prometheus::IntCounterVec;
7use prometheus::IntGaugeVec;
8use prometheus::Registry;
9use prometheus::register_histogram_vec_with_registry;
10use prometheus::register_int_counter_vec_with_registry;
11use prometheus::register_int_gauge_vec_with_registry;
12
13#[derive(Clone)]
14pub struct Metrics {
15 pub max_checkpoint_on_store: IntGaugeVec,
16 pub total_too_large_to_deserialize: IntCounterVec,
17 pub file_size_bytes: HistogramVec,
18 pub latest_uploaded_checkpoint: IntGaugeVec,
20 pub latest_uploaded_epoch: IntGaugeVec,
22}
23
24impl Metrics {
25 pub fn new(registry: &Registry) -> Self {
26 Self {
27 max_checkpoint_on_store: register_int_gauge_vec_with_registry!(
28 "max_checkpoint_on_store",
29 "Max checkpoint on the db table.",
30 &["pipeline"],
31 registry,
32 )
33 .unwrap(),
34 total_too_large_to_deserialize: register_int_counter_vec_with_registry!(
35 "total_too_large_to_deserialize",
36 "Total number of rows skipped due to size.",
37 &["pipeline"],
38 registry,
39 )
40 .unwrap(),
41 file_size_bytes: register_histogram_vec_with_registry!(
42 HistogramOpts::new("file_size_bytes", "Size of generated files in bytes.",)
43 .buckets(vec![
44 1_000.0, 10_000.0, 100_000.0, 1_000_000.0, 10_000_000.0, 50_000_000.0, 100_000_000.0, 250_000_000.0, 500_000_000.0, 1_000_000_000.0, 2_000_000_000.0, ]),
56 &["pipeline"],
57 registry,
58 )
59 .unwrap(),
60 latest_uploaded_checkpoint: register_int_gauge_vec_with_registry!(
61 "latest_uploaded_checkpoint",
62 "Latest checkpoint uploaded to object store (inclusive).",
63 &["pipeline"],
64 registry,
65 )
66 .unwrap(),
67 latest_uploaded_epoch: register_int_gauge_vec_with_registry!(
68 "latest_uploaded_epoch",
69 "Latest epoch uploaded to object store.",
70 &["pipeline"],
71 registry,
72 )
73 .unwrap(),
74 }
75 }
76}