feat: add metrics for nameko services 4

This commit is contained in:
BryantHe 2023-07-28 11:04:33 +08:00
parent c6c5289e44
commit c50e53ad53
1 changed files with 19 additions and 16 deletions

View File

@ -330,6 +330,7 @@ def metric_config_gen(module, class_name_str):
dest_dir = module.split('.')[0]
file_name = module.split('.')[-1]
_module = __import__(module)
config_list = []
for class_name in class_name_str.split(','):
members = inspect.getmembers(getattr(getattr(_module, file_name), class_name), predicate=inspect.isfunction)
@ -346,6 +347,7 @@ def metric_config_gen(module, class_name_str):
})
# Generate one file of statsd config yaml for statsd exporter
with status(f'Creating statsd_mapping.yml'):
metric_configs_dir = os.path.join(get_directory('chassis-agent'), 'metric-configs')
template_file_path = os.path.join(metric_configs_dir, 'statsd_mapping.yml.mako')
output_file = os.path.join('.', 'statsd_mapping.yml')
@ -357,6 +359,7 @@ def metric_config_gen(module, class_name_str):
with status(f'Creating directory {os.path.abspath("grafana_dashboards")!r}'):
os.makedirs('grafana_dashboards')
with status(f'Creating files of Grafana.json into the directory of grafana_dashboards'):
for class_name in class_name_str.split(','):
grafana_list = []
for config in config_list: