refactor: add basic counter metrics for IMC (#5006)

This commit is contained in:
Chethan Rao
2024-06-18 18:29:12 +05:30
committed by GitHub
parent 010e6fe3ee
commit d2092dcb0a
43 changed files with 301 additions and 316 deletions

View File

@ -120,3 +120,18 @@ macro_rules! gauge_metric {
> = once_cell::sync::Lazy::new(|| $meter.u64_observable_gauge($description).init());
};
}
pub use helpers::add_attributes;
mod helpers {
pub fn add_attributes<T, U>(attributes: U) -> Vec<opentelemetry::KeyValue>
where
T: Into<opentelemetry::Value>,
U: IntoIterator<Item = (&'static str, T)>,
{
attributes
.into_iter()
.map(|(key, value)| opentelemetry::KeyValue::new(key, value))
.collect::<Vec<_>>()
}
}