exploring-apm-traces
Skill này làm gì
Skill này chỉ cho agent cách đào sâu vào dữ liệu hiệu năng của PostHog cho các dịch vụ backend, như thời gian xử lý request và lỗi. Skill dành cho lập trình viên và người vận hành muốn tìm lý do một ứng dụng chậm hoặc lỗi.
Khi nào nên dùng
- ✓Khi bạn hỏi vì sao một dịch vụ chậm hoặc trả về lỗi.
- ✓Khi bạn cần tìm các lệnh gọi cơ sở dữ liệu hoặc request web chậm nhất trong ứng dụng.
- ✓Khi bạn muốn tra cứu một trace ID cụ thể và xem toàn bộ đường đi của request.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/products/tracing/skills/exploring-apm-traces/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Vì sao dịch vụ thanh toán của tôi chậm hôm nay? Hãy kiểm tra các trace và tìm những lệnh gọi tốn nhiều thời gian nhất.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent kiểm tra sức khỏe tổng thể của dịch vụ trước, rồi tìm các span, tức là các bước được đo thời gian bên trong mỗi request. Nó có thể mở toàn bộ một trace để xem đường đi của một request.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Exploring APM traces (OpenTelemetry spans)
PostHog captures distributed traces from OpenTelemetry. Each trace is a tree of spans representing a request's path through services.
Disambiguation: This skill is for APM / OpenTelemetry traces. Do not confuse with AI observability traces (agent/model $ai_* events) or logs (posthog:query-logs, posthog:logs-*).
Governed metric first
When the question asks for SLO burn, call posthog:metric-list before the APM tools and look for slo_explicit_burn_by_operation. Run an approved, non-drifted match with posthog:data-catalog-metric-run for the canonical headline. If the user also asks which operation drives the burn, answer the headline first, then use the aggregate and trace workflows below for a noncanonical breakdown. If no governed metric matches, say so and label the derived measure noncanonical.
Available tools
| Tool | Purpose |
|---|---|
posthog:apm-service-health |
Status per service against a baseline: start here |
posthog:query-apm-spans |
Search and filter spans (compact list view) |
posthog:apm-trace-get |
Get the full span list for one hex trace_id |
posthog:apm-spans-aggregate |
Per-operation aggregates (count, p50/p95, errors) |
posthog:apm-spans-tree |
Call-tree aggregates per (parent, child) edge |
posthog:apm-spans-count |
Scalar span count — cheap filter pre-flight |
posthog:apm-spans-sparkline |
Span counts over time (zero-filled time series) |
posthog:apm-spans-duration-histogram |
Trace counts per log-scale duration bucket |
posthog:apm-attribute-breakdown |
Span counts grouped by one attribute's value |
posthog:apm-services-list |
List distinct service names |
posthog:apm-attributes-list |
List span or resource attribute keys |
posthog:apm-attribute-values-list |
List values for a specific attribute key |
See references/spans-and-fields.md for the response schema and the kind/status_code enums.
Workflow: debug a trace from a URL
Step 1 — Fetch the trace
posthog:apm-trace-get
{
"trace_id": "<hex_trace_id>"
}
The response is { results: [span, span, …], _posthogUrl: "…" } — a flat list of every span in the trace.
The list can be very large for fan-out request flows; when it exceeds the inline limit, Claude Code auto-persists it to a file.
From the result you get:
- Every span with
name,service_name,kind,status_code,parent_span_id,duration_nano,is_root_span - The
_posthogUrl— a deep link to this trace in the tracing UI; always include this in your response so the user can click through
Step 2 — Parse large results with scripts
When the result is persisted to a file (traces with hundreds of spans across services), use the parsing scripts to explore it.
Start with the summary to get the full picture, then drill into specifics:
# 1. Overview: services, span count, slowest spans, errors
python3 scripts/print_summary.py /path/to/persisted-file.json
# 2. Indented chronological tree (DFS by parent_span_id)
python3 scripts/print_timeline.py /path/to/persisted-file.json
# 3. Drill into a specific span by name
SPAN="HTTP GET /api/users" python3 scripts/extract_span.py /path/to/persisted-file.json
# 4. Search for a keyword across span names, services, IDs
SEARCH="keyword" python3 scripts/search_spans.py /path/to/persisted-file.json
# 5. When the JSON shape looks unfamiliar
python3 scripts/show_structure.py /path/to/persisted-file.json
All scripts support MAX_LEN=N env var to control truncation (0 = unlimited).
Tree reconstruction (parent_span_id → span_id)
The flat span list is a tree. Each span carries:
trace_id— same on every span in the tracespan_id— this span's unique hex IDparent_span_id— points to the parent'sspan_id(zero-padded hex000…000for the root)is_root_span— convenience flag for the trace entry
To rebuild the tree:
- Spans where
is_root_spanis true (orparent_span_id == "00000000…") are root spans. - Every other span is a child of the s
Câu hỏi thường gặp
Đây có giống trace AI hoặc log sản phẩm không?
Không. Skill này bao quát trace hiệu năng từ OpenTelemetry, không phải trace mô hình AI hay log chung.
Agent nên bắt đầu từ đâu?
Nó bắt đầu từ sức khỏe dịch vụ, so sánh mỗi dịch vụ với mức nền trước khi xem chi tiết.
Nó có kiểm tra một chỉ số chính thức trước không?
Có. Với các câu hỏi về SLO burn, nó tìm một chỉ số PostHog đã được phê duyệt và dùng nó làm câu trả lời chính.
Chi tiết
Mô tả gốc của tác giả
Investigates distributed application performance using PostHog APM (OpenTelemetry span) data via MCP. Use when the user asks about service traces, slow HTTP/database spans, error spans, error-rate trends or spikes, latency distributions, trace IDs, or span attributes — not AI observability traces or product logs. Uses posthog:apm-service-health, posthog:query-apm-spans, posthog:apm-trace-get, posthog:apm-spans-sparkline, posthog:apm-services-list, posthog:apm-attributes-list, and posthog:apm-attribute-values-list.
repo: PostHog/posthog
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6964
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
openclaw-update
394kGiúp agent của bạn cập nhật OpenClaw Gateway đang có, chọn cách cập nhật phù hợp với cách cài đặt và giữ phiên làm việc của bạn hoạt động.
diagnose-gateway
394kGiúp agent của bạn tìm hiểu vì sao OpenClaw Gateway bị lỗi bằng cách kiểm tra cài đặt, kênh và cổng mà không thay đổi gì.
crabbox-apps
394kGiúp agent của bạn mở và chạy một app trên máy đám mây tạm thời, rồi hiển thị giao diện của nó trong thanh bên của chat.