Skip to content

Commit

Permalink
refactor: replace RdKafkaStats with Guarded metrics (#18462)
Browse files Browse the repository at this point in the history
Signed-off-by: tabVersion <[email protected]>
  • Loading branch information
tabVersion authored Sep 10, 2024
1 parent 2679396 commit 952962c
Show file tree
Hide file tree
Showing 3 changed files with 323 additions and 260 deletions.
18 changes: 18 additions & 0 deletions src/common/metrics/src/guarded_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ macro_rules! register_guarded_int_gauge_vec_with_registry {
}};
}

#[macro_export]
macro_rules! register_guarded_uint_gauge_vec_with_registry {
($NAME:expr, $HELP:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{
let inner = prometheus::core::GenericGaugeVec::<AtomicU64>::new(
prometheus::opts!($NAME, $HELP),
$LABELS_NAMES,
);
inner.and_then(|inner| {
let inner = $crate::__extract_gauge_builder(inner);
let label_guarded = $crate::LabelGuardedUintGaugeVec::new(inner, { $LABELS_NAMES });
let result = ($REGISTRY).register(Box::new(label_guarded.clone()));
result.map(move |()| label_guarded)
})
}};
}

#[macro_export]
macro_rules! register_guarded_int_counter_vec_with_registry {
($NAME:expr, $HELP:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{
Expand Down Expand Up @@ -131,6 +147,8 @@ pub type LabelGuardedIntCounterVec<const N: usize> =
LabelGuardedMetricVec<VecBuilderOfCounter<AtomicU64>, N>;
pub type LabelGuardedIntGaugeVec<const N: usize> =
LabelGuardedMetricVec<VecBuilderOfGauge<AtomicI64>, N>;
pub type LabelGuardedUintGaugeVec<const N: usize> =
LabelGuardedMetricVec<VecBuilderOfGauge<AtomicU64>, N>;
pub type LabelGuardedGaugeVec<const N: usize> =
LabelGuardedMetricVec<VecBuilderOfGauge<AtomicF64>, N>;

Expand Down
2 changes: 1 addition & 1 deletion src/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub mod memory;
pub use risingwave_common_metrics::{
monitor, register_guarded_gauge_vec_with_registry,
register_guarded_histogram_vec_with_registry, register_guarded_int_counter_vec_with_registry,
register_guarded_int_gauge_vec_with_registry,
register_guarded_int_gauge_vec_with_registry, register_guarded_uint_gauge_vec_with_registry,
};
pub use {
risingwave_common_metrics as metrics, risingwave_common_secret as secret,
Expand Down
Loading

0 comments on commit 952962c

Please sign in to comment.