Skip to content

perf: 遥测上传失败节点 - #303

Merged
MistEO merged 3 commits into
MistEO:mainfrom
zmdyy0318:perf/2026072901
Jul 29, 2026
Merged

perf: 遥测上传失败节点#303
MistEO merged 3 commits into
MistEO:mainfrom
zmdyy0318:perf/2026072901

Conversation

@zmdyy0318

@zmdyy0318 zmdyy0318 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

opus 5.0
image

Summary by Sourcery

在遥测中将失败的流水线节点作为任务 span 下的子 span 进行附加,以为 Maa 任务提供详细、可追踪的失败链路(包括嵌套流水线和时间信息),同时对每个任务的 span 数量施加限制。

New Features:

  • 在任务 span 之上为失败的流水线节点创建子 span,以捕获 Maa 流水线中的细粒度失败点。
  • 追踪流水线步骤的开始时间,以记录任务在失败节点上卡住的时长。
  • 在遥测中支持将嵌套子流水线的失败归因并标记到其所属任务下。
  • 在 span 上暴露 MaaFW 任务 ID 和流水线节点元数据,以帮助与用户日志进行关联。

Enhancements:

  • 用结构化的、按节点划分的失败 span 和按任务限制,替换单一失败节点标签,以避免超过 Sentry 的 span 上限。
  • 在任务完成时清理与该任务相关的遥测状态,包括步骤计时、失败次数、嵌套流水线条目以及活跃任务跟踪信息。
Original summary in English

Summary by Sourcery

Attach failed pipeline nodes as child spans under task spans in telemetry to provide a detailed, traceable failure chain for Maa tasks, including nested pipelines and timing information, while enforcing per-task span limits.

New Features:

  • Create child spans for failed pipeline nodes on top of task spans to capture granular failure points in Maa pipelines.
  • Track pipeline step start times to record how long tasks are stuck on failed nodes.
  • Support attribution and labeling of failures from nested sub-pipelines under their owning tasks in telemetry.
  • Expose MaaFW task IDs and pipeline node metadata on spans to aid correlation with user logs.

Enhancements:

  • Replace single failed-node tagging with structured per-node failure spans and per-task limits to avoid exceeding Sentry span caps.
  • Clean up per-task telemetry state on task completion, including step timing, failure counts, nested pipeline entries, and active task tracking.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

嗨,我在这里给出了一些总体反馈:

  • active_tasknested_entries 这部分逻辑假设 Context::run_task 的执行是单线程并且严格串行的;如果存在任务重叠或可重入的可能性,最好在文档中明确说明这一假设,或者增加保护措施,以避免将节点失败错误地归属到错误的父 span。
  • record_failed_node 中,failed_nodes 会在检查是否存在 task_span 之前就递增,这意味着有些失败会被计数但不会真正体现为 span;可以考虑在成功获取父 span 之后再进行限流计数,这样该计数器就能反映真正上报的节点 span。
面向 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- The `active_task` and `nested_entries` logic assumes a single-threaded, strictly serial `Context::run_task` flow; if there is any chance of overlapping tasks or re-entrancy, it would be safer to document that assumption clearly or add guards to avoid mis-attributing node failures to the wrong parent span.
- In `record_failed_node`, `failed_nodes` is incremented before checking whether a `task_span` exists, which means some failures are counted but never materialize as spans; consider moving the rate-limiting increment after successfully obtaining the parent span so the counter reflects actual reported node spans.

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点击 👍 或 👎,我会根据你的反馈改进后续的代码评审。
Original comment in English

Hey - I've left some high level feedback:

  • The active_task and nested_entries logic assumes a single-threaded, strictly serial Context::run_task flow; if there is any chance of overlapping tasks or re-entrancy, it would be safer to document that assumption clearly or add guards to avoid mis-attributing node failures to the wrong parent span.
  • In record_failed_node, failed_nodes is incremented before checking whether a task_span exists, which means some failures are counted but never materialize as spans; consider moving the rate-limiting increment after successfully obtaining the parent span so the counter reflects actual reported node spans.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `active_task` and `nested_entries` logic assumes a single-threaded, strictly serial `Context::run_task` flow; if there is any chance of overlapping tasks or re-entrancy, it would be safer to document that assumption clearly or add guards to avoid mis-attributing node failures to the wrong parent span.
- In `record_failed_node`, `failed_nodes` is incremented before checking whether a `task_span` exists, which means some failures are counted but never materialize as spans; consider moving the rate-limiting increment after successfully obtaining the parent span so the counter reflects actual reported node spans.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

zmdyy0318 and others added 2 commits July 29, 2026 22:34
Co-authored-by: Cursor <cursoragent@cursor.com>
@MistEO
MistEO merged commit d4eac31 into MistEO:main Jul 29, 2026
9 checks passed
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.

2 participants