Skip to content
Skillpedia
Deploy & cloud (DevOps)41k · #6871

linking-errors-to-traces

What it does

This skill links an error to the backend trace, logs and session recording that share its ID. It is for developers who want to follow a problem from the front end into the server.

When to use it

  • ✓When you want the trace or span ID for a specific error occurrence.
  • ✓When you need the backend logs that share a trace ID with an error.
  • ✓When you want to see the session replay and backend traces for the errors in one session.

Skill link

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

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/PostHog/posthog/blob/master/products/error_tracking/skills/linking-errors-to-traces/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Find the backend trace and logs that belong to this error occurrence, so I can see what the server did.”

5 new skills a week. 1 minute to read.

How it works

It starts from an error or session ID, follows the shared trace ID to the matching spans and logs, and checks the session replay. It only links records that share an ID, not records that just happen at a similar time.

Technical content (original SKILL.md)

Original text by the author, straight from 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.

FAQ

Why does it need a shared ID?

Matching only by service and time can link the wrong records, so the skill requires a shared trace ID.

What if no trace is found?

The skill reports the time window it searched. Logs may still exist even when no span is found.

Can it give a general diagnosis?

No. For a general diagnosis or a replay summary, other error investigation skills are used.

Details

Original description by the author

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

Popularity

GitHub stars
41k
Ranking position
#6871
License
—
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills