跳到正文
Skillpedia
部署与云(DevOps)41k · #6871

linking-errors-to-traces

它能做什么

本技能将某个错误与共享其 ID 的后端追踪、日志和会话录制关联起来。适合希望从前端一路追踪问题到服务器的开发者。

适用场景

  • ✓当你想获取某次具体错误发生时的追踪或 span ID 时。
  • ✓当你需要与某个错误共享追踪 ID 的后端日志时。
  • ✓当你想在同一会话中查看错误对应的会话回放和后端追踪时。

技能链接

https://github.com/PostHog/posthog/blob/master/products/error_tracking/skills/linking-errors-to-traces/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/PostHog/posthog/blob/master/products/error_tracking/skills/linking-errors-to-traces/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请找出这次错误发生对应的后端追踪和日志,以便我了解服务器做了什么。”

每周 5 个新技能,1 分钟读完。

工作原理

它从某个错误或会话 ID 出发,沿着共享的追踪 ID 找到对应的 span 和日志,并检查会话回放。它只关联共享同一 ID 的记录,而不会关联仅发生在相近时间的记录。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Link errors to traces and logs

Use a shared ID to connect records. A matching service and time do not prove that a log or span belongs to an error.

Find the exception

For an issue ID or URL, call posthog:query-error-tracking-issue-events with include: ["exception", "correlation"], filterTestAccounts: false, and a small limit. Choose one occurrence unless the user asks for several. Say when the result is a sample.

For an occurrence ID or session ID, read finding-exceptions.md for the exact lookup. Use the user's time range when given. If no event appears, state the window you checked. Do not claim that an event never existed based on a bounded search.

Follow the IDs

  1. Replay: If the event has $session_id, call posthog:session-recording-get with that ID. found: false means no recording was found; the error or session may still exist. Use posthog:generate-app-url with /replay/{id} when a recording exists.
  2. Exact trace: For each unique, nonzero, 32-character hex $trace_id, call posthog:apm-trace-get with that ID and excludeAttributes: true. Use its _posthogUrl for the trace link. If the event has $span_id, compare it with returned span IDs as hex, ignoring case. An empty result means no retained span was found for that trace ID. Logs may still exist.
  3. Session trace candidates: If an event lacks $trace_id and the user asked about session traces, use posthog:apm-attributes-list to find a span attribute that stores the session ID. If a clear key exists, call posthog:query-apm-spans with an exact span_attribute filter, a short window around the error, flatSpans: true, and a small limit. This finds matching child spans as well as root spans. Call posthog:apm-trace-get for a candidate that needs a link. Label these as session matches. Time alone does not prove which request raised the error.
  4. Same-trace logs: When an event has a trace ID, read finding-trace-logs.md for the bounded service lookup and exact log filter. Include every severity, including info. A trace can have logs even when no span was retained.

Use posthog:generate-app-url with /error-tracking/{id} when the issue ID is known. Do not build PostHog links by hand.

Report the result

For each checked occurrence, show the error time, IDs used for the join, and links to the issue, replay, and retained trace when available. Summarize matching logs with their time and severity. Exclude secrets and unneeded personal data from log excerpts.

Name each gap separately: no trace ID on the event, trace ID but no retained span, no session attribute on spans, no recording, or no logs with that trace ID in the checked window. A session-matched span is a candidate until an exact trace or span ID connects it to the error. State any row limit or time range that kept the search from being complete. If a lookup fails, say that its result is unknown instead of reporting that no matching data exists.

常见问题

为什么需要共享 ID?

仅按服务和时间匹配可能会关联错误的记录,因此本技能要求共享追踪 ID。

如果找不到追踪怎么办?

本技能会报告它所搜索的时间范围。即使未找到 span,日志仍可能存在。

它能给出综合诊断吗?

不能。综合诊断或回放摘要需要使用其他错误调查技能。

详情

作者的原始描述

Links a PostHog error occurrence or session's errors to OpenTelemetry traces, logs with the same trace ID, and Session Replay. Use when the user asks for trace or span IDs on an error, same-trace logs, or backend traces for errors in a session. Starts from an occurrence UUID, session ID, or error tracking issue URL. For a general issue diagnosis or replay summary, use investigating-error-issue or investigating-replay.

repo: PostHog/posthog

热度

GitHub 星标
41k
排名
#6871
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能