Skip to content

增加监控导出计数器汇总结构化输出#6

Open
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mxexporter-counter-summary-json
Open

增加监控导出计数器汇总结构化输出#6
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mxexporter-counter-summary-json

Conversation

@ghangz

@ghangz ghangz commented Jun 10, 2026

Copy link
Copy Markdown

这次改动补上了监控导出计数器汇总结构化输出,主要是为了解决监控导出与部署排查流程里相关信息不够集中、人工整理成本较高的问题,让日常排查、验证和结果归档更直接。

实现上补充了对应工具或脚本逻辑,补上了对应测试,同时尽量保持现有用法不变,避免影响已有流程。

这一分支已经在沐曦算力环境完成实际验证,相关检查均已通过,现提交合入。

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +22 to +26
metric_type = row[1].strip()
metric_name = row[2].strip()
type_counts[metric_type] += 1
if metric_name:
metric_names.append(metric_name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

如果 metric_name 为空,当前逻辑仍会增加 type_counts[metric_type] 的计数,但不会将该指标加入 metric_names。这会导致最终输出的 metric_count(即 len(metric_names))与 type_counts 的各项之和不一致。建议仅在 metric_namemetric_type 均非空时才进行统计,以保证数据的一致性。

Suggested change
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)

Comment on lines +45 to +47
args = parser.parse_args()

payload = summarize(args.path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

如果指定的 path 文件不存在(例如默认路径不存在,或者用户输入了错误的路径),程序在调用 summarize(args.path) 时会抛出 FileNotFoundError 堆栈信息。作为 CLI 工具,建议在解析参数后先检查文件是否存在,并使用 parser.error() 提供更友好的错误提示。

    args = parser.parse_args()

    if not args.path.is_file():
        parser.error(f"Input file does not exist: {args.path}")

    payload = summarize(args.path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant