AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

linking-errors-to-traces

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.

Original source
posthog
License
MIT
Pinned revision
cac7c80a9e5b73484d18eda1bffb47297c938e0c

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read posthog--linking-errors-to-traces at revision cac7c80a9e5b73484d18eda1bffb47297c938e0c, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 3

references/finding-trace-logs.md

Find logs with the same trace ID

For each unique trace ID, use the bounded SQL query below to find services with logs for that trace, even when retained spans name some services. Add any service names from the retained trace. logs-attribute-values-list cannot filter service values by trace ID. If no service is found, do not make an unscoped log query.

Raw logs.trace_id values use base64. Convert the validated hex ID in the predicate, and use a short time window around the error. The 21st row shows when the first 20 services are incomplete. Narrow the window and retry if a complete list matters; otherwise report the limit.

posthog:execute-sql
SELECT service_name, count() AS log_count
FROM logs
WHERE trace_id = base64Encode(unhex('<trace_id>'))
    AND timestamp >= '<before_error>'
    AND timestamp < '<after_error>'
GROUP BY service_name
ORDER BY log_count DESC
LIMIT 21

Call posthog:logs-count, then posthog:query-logs with the same trace ID, services, and time window. Use this filter shape. Use the same filters without limit for posthog:logs-count. Keep the row limit small and narrow the window if the count is large.

{
  "query": {
    "serviceNames": ["<service_name>"],
    "dateRange": { "date_from": "<before_error>", "date_to": "<after_error>" },
    "filterGroup": [
      {
        "key": "trace_id",
        "type": "log",
        "operator": "exact",
        "value": "<trace_id>"
      }
    ],
    "limit": 50
  }
}