fuel_core_metrics/
config.rsuse once_cell::sync::Lazy;
use strum::IntoEnumIterator;
use strum_macros::{
Display,
EnumIter,
EnumString,
};
#[derive(Debug, Display, Clone, Copy, PartialEq, EnumString, EnumIter)]
#[strum(serialize_all = "lowercase")]
pub enum Module {
All,
Importer,
P2P,
Producer,
TxPool, GraphQL, }
pub trait DisableConfig {
fn is_enabled(&self, module: Module) -> bool;
fn list_of_enabled(&self) -> Vec<Module>;
}
impl DisableConfig for Vec<Module> {
fn is_enabled(&self, module: Module) -> bool {
!self.contains(&module) && !self.contains(&Module::All)
}
fn list_of_enabled(&self) -> Vec<Module> {
Module::iter()
.filter(|module| self.is_enabled(*module) && *module != Module::All)
.collect()
}
}
static HELP_STRING: Lazy<String> = Lazy::new(|| {
let all_modules: Vec<_> = Module::iter().map(|module| module.to_string()).collect();
format!(
"Comma-separated list of modules or 'all' to disable all metrics. Available options: {}, all",
all_modules.join(", ")
)
});
pub fn help_string() -> &'static str {
&HELP_STRING
}