fuel_core_metrics/
config.rs1use once_cell::sync::Lazy;
2use strum::IntoEnumIterator;
3use strum_macros::{
4 Display,
5 EnumIter,
6 EnumString,
7};
8
9#[derive(Debug, Display, Clone, Copy, PartialEq, EnumString, EnumIter)]
10#[strum(serialize_all = "lowercase")]
11pub enum Module {
12 All,
13 Importer,
14 P2P,
15 Producer,
16 TxPool,
17 GraphQL, GasPrice,
19 TxStatusManager,
20 Compression,
21 PoA,
22}
23
24pub trait DisableConfig {
26 fn is_enabled(&self, module: Module) -> bool;
28
29 fn list_of_enabled(&self) -> Vec<Module>;
31}
32
33impl DisableConfig for Vec<Module> {
34 fn is_enabled(&self, module: Module) -> bool {
35 !self.contains(&module) && !self.contains(&Module::All)
36 }
37
38 fn list_of_enabled(&self) -> Vec<Module> {
39 Module::iter()
40 .filter(|module| self.is_enabled(*module) && *module != Module::All)
41 .collect()
42 }
43}
44
45static HELP_STRING: Lazy<String> = Lazy::new(|| {
46 let all_modules: Vec<_> = Module::iter().map(|module| module.to_string()).collect();
47 format!(
48 "Comma-separated list of modules or 'all' to disable all metrics. Available options: {}, all",
49 all_modules.join(", ")
50 )
51});
52
53pub fn help_string() -> &'static str {
54 &HELP_STRING
55}