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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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
- Replay: If the event has
$session_id, callposthog:session-recording-getwith that ID.found: falsemeans no recording was found; the error or session may still exist. Useposthog:generate-app-urlwith/replay/{id}when a recording exists. - Exact trace: For each unique, nonzero, 32-character hex
$trace_id, callposthog:apm-trace-getwith that ID andexcludeAttributes: true. Use its_posthogUrlfor 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. - Session trace candidates: If an event lacks
$trace_idand the user asked about session traces, useposthog:apm-attributes-listto find a span attribute that stores the session ID. If a clear key exists, callposthog:query-apm-spanswith an exactspan_attributefilter, a short window around the error,flatSpans: true, and a smalllimit. This finds matching child spans as well as root spans. Callposthog:apm-trace-getfor a candidate that needs a link. Label these as session matches. Time alone does not prove which request raised the error. - 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
评论
- …
同一仓库的更多技能
depot-ci
41k帮你的智能体设置并运行 Depot CI 工作流(GitHub Actions 的替代方案),包括迁移现有工作流和读取运行日志。
depot-container-builds
41k帮你的智能体在 Depot 的远程构建器上构建 Docker 镜像,包括多平台镜像、推送到镜像仓库,以及修复构建失败。
depot-github-runners
41k帮你的智能体把 GitHub Actions 任务迁移到 Depot 托管的运行器上,选择运行器规格和标签,并排查运行器设置问题。
editing-agents-md
41k帮你的智能体判断某条规则应写入 AGENTS.md 还是 CLAUDE.md,并以不会让文件臃肿的方式写下,确保规则真正生效。