Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

7.4 KB
Raw Blame
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "properties": {
        "query": {
            "description": "The tracing spans query to execute.",
            "properties": {
                "after": {
                    "description": "Keyset pagination cursor from a previous timestamp-ordered response.",
                    "type": "string"
                },
                "dateRange": {
                    "description": "Date range for the query. Defaults to last hour.",
                    "properties": {
                        "date_from": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "description": "Start of the date range. Accepts ISO 8601 timestamps or relative formats: -1h, -6h, -1d, -7d, etc."
                        },
                        "date_to": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "description": "End of the date range. Same format as date_from. Omit or null for \"now\"."
                        }
                    },
                    "type": "object"
                },
                "excludeAttributes": {
                    "default": false,
                    "description": "Omit the per-span attributes and resource attributes maps from results to keep payloads compact. Defaults to false.",
                    "type": "boolean"
                },
                "filterGroup": {
                    "default": [],
                    "description": "Property filters for the query.",
                    "items": {
                        "properties": {
                            "key": {
                                "description": "Attribute key. For type \"span\", use built-in fields (trace_id, span_id, duration, name, kind, status_code, is_root_span). For \"span_attribute\"/\"span_resource_attribute\", use the attribute key (e.g. \"http.method\").",
                                "type": "string"
                            },
                            "operator": {
                                "description": "Comparison operator.\n\n* `exact` - exact\n* `is_not` - is_not\n* `icontains` - icontains\n* `not_icontains` - not_icontains\n* `starts_with` - starts_with\n* `not_starts_with` - not_starts_with\n* `ends_with` - ends_with\n* `not_ends_with` - not_ends_with\n* `regex` - regex\n* `not_regex` - not_regex\n* `gt` - gt\n* `lt` - lt\n* `is_set` - is_set\n* `is_not_set` - is_not_set",
                                "enum": [
                                    "exact",
                                    "is_not",
                                    "icontains",
                                    "not_icontains",
                                    "starts_with",
                                    "not_starts_with",
                                    "ends_with",
                                    "not_ends_with",
                                    "regex",
                                    "not_regex",
                                    "gt",
                                    "lt",
                                    "is_set",
                                    "is_not_set"
                                ],
                                "type": "string"
                            },
                            "type": {
                                "description": "\"span\" filters built-in span fields. \"span_attribute\" filters span-level attributes. \"span_resource_attribute\" filters resource-level attributes.\n\n* `span` - span\n* `span_attribute` - span_attribute\n* `span_resource_attribute` - span_resource_attribute",
                                "enum": ["span", "span_attribute", "span_resource_attribute"],
                                "type": "string"
                            },
                            "value": {
                                "description": "Value to compare against. String, number, or array of strings. Omit for is_set/is_not_set operators."
                            }
                        },
                        "required": ["key", "type", "operator"],
                        "type": "object"
                    },
                    "type": "array"
                },
                "flatSpans": {
                    "default": false,
                    "description": "Return the matching spans themselves, one row per span (root and child), instead of collapsing to traces. Use this to search by a child-span attribute (e.g. code.filepath) without the whole-trace grouping. Distinct from rootSpans. Defaults to false.",
                    "type": "boolean"
                },
                "limit": {
                    "default": 100,
                    "description": "Max results (1-1000). Defaults to 100.",
                    "type": "number"
                },
                "offset": {
                    "description": "Pagination offset, used when ordering by a column (e.g. duration). Defaults to 0.",
                    "minimum": 0,
                    "type": "number"
                },
                "orderBy": {
                    "description": "Column to order by. Defaults to timestamp. Ordering by timestamp paginates via the keyset cursor ('after'); ordering by duration paginates via 'offset'.\n\n* `timestamp` - timestamp\n* `duration` - duration",
                    "enum": ["timestamp", "duration"],
                    "type": "string"
                },
                "orderDirection": {
                    "description": "Order direction. Defaults to DESC (e.g. timestamp+DESC = newest first, duration+DESC = slowest first).\n\n* `ASC` - ASC\n* `DESC` - DESC",
                    "enum": ["ASC", "DESC"],
                    "type": "string"
                },
                "prefetchSpans": {
                    "description": "Number of child spans to prefetch per trace (1-100).",
                    "type": "number"
                },
                "rootSpans": {
                    "default": true,
                    "description": "Filter to root spans only. Defaults to true.",
                    "type": "boolean"
                },
                "serviceNames": {
                    "description": "Filter by service names.",
                    "items": {
                        "type": "string"
                    },
                    "type": "array"
                },
                "statusCodes": {
                    "description": "Filter by OTel span status codes (0 Unset, 1 OK, 2 Error) — not HTTP status codes. Use [2] to select error spans.",
                    "items": {
                        "type": "number"
                    },
                    "type": "array"
                },
                "traceId": {
                    "description": "Filter to a specific trace ID (hex string).",
                    "type": "string"
                }
            },
            "type": "object"
        }
    },
    "required": ["query"],
    "type": "object"
}