Macro declare_observable_gauge

Source
macro_rules! declare_observable_gauge {
    ($name:ident, $key:expr_2021, $cb:expr_2021) => { ... };
}
Expand description

Create a thread safe static observable gauge that can be set to a specific value based on the provided callback. This is useful for metrics that need to be calculated or retrieved dynamically. The callback will be executed whenever the gauge is observed by the metrics system.

Example:


declare_observable_gauge!(MEMORY_USAGE_GAUGE, "memory_usage", |observer| {
    // Simulate getting memory usage - this could be any complex operation
    observer.observe(512.0, &[]);
});

// The gauge will be automatically updated when observed