exploring-apm-traces
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExploring APM traces (OpenTelemetry spans)
探索APM追踪(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 LLM analytics traces (agent/model events and LLM observability tools) or logs (, ).
$ai_*posthog:query-logsposthog:logs-*PostHog 采集来自 OpenTelemetry 的分布式追踪数据。每个追踪都是由span组成的树状结构,代表请求在各个服务间的路径。
说明: 本技能适用于APM / OpenTelemetry 追踪。请勿与LLM分析追踪(智能体/模型的事件及LLM可观测性工具)或日志(、)混淆。
$ai_*posthog:query-logsposthog:logs-*MCP tools
MCP工具
| Tool | Purpose |
|---|---|
| Search and filter spans (analytics-style query; parameters live under |
| Fetch all spans for a hex |
| List distinct service names |
| List span or resource attribute keys |
| List values for a specific attribute key |
For aggregates or joins not covered by these tools, may be appropriate once the span schema is confirmed for the project.
posthog:execute-sql| 工具名称 | 用途 |
|---|---|
| 搜索和过滤span(类分析查询;参数位于 |
| 根据十六进制 |
| 列出所有不同的服务名称 |
| 列出span或资源属性的键名 |
| 列出指定属性键对应的所有值 |
如果这些工具无法满足聚合或关联需求,在确认项目的span schema后,可能是合适的选择。
posthog:execute-sqlSpan data model
Span数据模型
| Field | Description |
|---|---|
| Hex ID linking spans in one trace |
| Hex ID for this span |
| Parent span hex ID (null for root) |
| Operation name (e.g. |
| 0=Unspecified, 1=Internal, 2=Server, 3=Client, 4=Producer, 5=Consumer |
| Emitting service |
| 0=Unset, 1=OK, 2=Error |
| Start time (ISO 8601) |
| End time (ISO 8601) |
| Duration in nanoseconds |
| Whether this is the trace entry |
| 字段名 | 描述 |
|---|---|
| 关联同一追踪中所有span的十六进制ID |
| 当前span的十六进制ID |
| 父span的十六进制ID(根span为null) |
| 操作名称(例如 |
| 类型:0=未指定,1=内部,2=服务端,3=客户端,4=生产者,5=消费者 |
| 发送span的服务名称 |
| 状态码:0=未设置,1=正常,2=错误 |
| 开始时间(ISO 8601格式) |
| 结束时间(ISO 8601格式) |
| 持续时间(纳秒) |
| 是否为追踪的入口span |
Property filter types (query.filterGroup
)
query.filterGroup属性过滤类型(query.filterGroup
)
query.filterGroup- — built-in fields:
span,trace_id,span_id,duration,name,kindstatus_code - — span-level attributes (e.g.
span_attribute)http.method - — resource attributes (e.g. Kubernetes labels)
span_resource_attribute
- — 内置字段:
span、trace_id、span_id、duration、name、kindstatus_code - — span级属性(例如
span_attribute)http.method - — 资源属性(例如Kubernetes标签)
span_resource_attribute
Workflow: investigate slow requests
工作流:排查缓慢请求
- Discover services: call with
posthog:apm-services-list(or applicable filters per tool schema).{} - Find slow spans: with a
posthog:query-apm-spansthat filters by service andquery(remember nanoseconds: 1s = 1_000_000_000).duration - Drill in: with
posthog:apm-trace-get.{ "trace_id": "<hex from step 2>" }
- 发现服务:调用并传入
posthog:apm-services-list(或根据工具schema传入适用的过滤器)。{} - 查找慢span:使用,传入按服务和
posthog:query-apm-spans过滤的duration(注意单位是纳秒:1秒=1_000_000_000)。query - 深入分析:调用并传入
posthog:apm-trace-get。{ "trace_id": "<步骤2中获取的十六进制ID>" }
Workflow: find error traces
工作流:查找错误追踪
Use with on / numeric operators as appropriate — OpenTelemetry status 2 means error.
posthog:query-apm-spansquery.filterGroupstatus_codeexact使用,在中对设置精确匹配或数值操作符——OpenTelemetry中状态码2表示错误。
posthog:query-apm-spansquery.filterGroupstatus_codeWorkflow: explore unknown attributes
工作流:探索未知属性
- — narrow keys (e.g. search
posthog:apm-attributes-list)."http" - — inspect values for a chosen key.
posthog:apm-attribute-values-list - Build filters in using the discovered keys.
posthog:query-apm-spans
- — 筛选键名(例如搜索
posthog:apm-attributes-list)。"http" - — 查看指定键对应的所有值。
posthog:apm-attribute-values-list - 在中使用发现的键构建过滤器。
posthog:query-apm-spans
Reminders
注意事项
- Prefer discovering attribute keys and services before guessing filters.
- Durations in filters are in nanoseconds.
- expects a
query-apm-spanswrapper object; defaults often assume a recent time window — tightenquerywhen the question implies it.query.dateRange
- 建议先发现属性键和服务,再尝试设置过滤器。
- 过滤器中的持续时间单位为纳秒。
- 需要传入**
query-apm-spans**包装对象;默认通常假设最近的时间窗口——当问题涉及特定时间段时,需缩小query的范围。query.dateRange