增加监控导出计数器汇总结构化输出#6
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new utility script tools/summarize_counters.py along with its corresponding unit tests in tests/test_summarize_counters.py. The script parses mx-exporter counter CSV files to generate a JSON summary of metric counts, types, and duplicate metric names. The review feedback suggests two improvements: ensuring data consistency by only counting metrics when both the type and name are non-empty, and enhancing CLI error handling by validating that the input file exists before processing to avoid raw stack traces.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| metric_type = row[1].strip() | ||
| metric_name = row[2].strip() | ||
| type_counts[metric_type] += 1 | ||
| if metric_name: | ||
| metric_names.append(metric_name) |
There was a problem hiding this comment.
如果 metric_name 为空,当前逻辑仍会增加 type_counts[metric_type] 的计数,但不会将该指标加入 metric_names。这会导致最终输出的 metric_count(即 len(metric_names))与 type_counts 的各项之和不一致。建议仅在 metric_name 和 metric_type 均非空时才进行统计,以保证数据的一致性。
| metric_type = row[1].strip() | |
| metric_name = row[2].strip() | |
| type_counts[metric_type] += 1 | |
| if metric_name: | |
| metric_names.append(metric_name) | |
| metric_type = row[1].strip() | |
| metric_name = row[2].strip() | |
| if metric_type and metric_name: | |
| type_counts[metric_type] += 1 | |
| metric_names.append(metric_name) |
| args = parser.parse_args() | ||
|
|
||
| payload = summarize(args.path) |
There was a problem hiding this comment.
这次改动补上了监控导出计数器汇总结构化输出,主要是为了解决监控导出与部署排查流程里相关信息不够集中、人工整理成本较高的问题,让日常排查、验证和结果归档更直接。
实现上补充了对应工具或脚本逻辑,补上了对应测试,同时尽量保持现有用法不变,避免影响已有流程。
这一分支已经在沐曦算力环境完成实际验证,相关检查均已通过,现提交合入。