Tracing

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

GET
POST
GET
PATCH
DELETE
POST
POST
POST
POST
GET
POST
POST
POST
GET
POST
POST
POST
GET
POST

List all tracing retention rules

Span retention rules.

Shares the logs implementation over its own model. Only the model, the access-control scope and the feature flag differ.

Required API key scopes

tracing:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/projects/:project_id/tracing/retention_rules
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/retention_rules/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}

Create tracing retention rules

Span retention rules.

Shares the logs implementation over its own model. Only the model, the access-control scope and the feature flag differ.

Required API key scopes

tracing:write

Request parameters

  • name
    string
  • enabled
    boolean
    Default: false
  • priority
    integer | null
  • config

Response


Example request

POST /api/projects/:project_id/tracing/retention_rules
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/retention_rules/\
-d name="string",\
-d config=undefined

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Retrieve tracing retention rules

Span retention rules.

Shares the logs implementation over its own model. Only the model, the access-control scope and the feature flag differ.

Required API key scopes

tracing:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/tracing/retention_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/retention_rules/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Update tracing retention rules

Span retention rules.

Shares the logs implementation over its own model. Only the model, the access-control scope and the feature flag differ.

Required API key scopes

tracing:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • enabled
    boolean
    Default: false
  • priority
    integer | null
  • config

Response


Example request

PATCH /api/projects/:project_id/tracing/retention_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/retention_rules/:id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Delete tracing retention rules

Span retention rules.

Shares the logs implementation over its own model. Only the model, the access-control scope and the feature flag differ.

Required API key scopes

tracing:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/tracing/retention_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/retention_rules/:id/

Example response

Status 204 No response body

Create tracing retention rules reorder

Atomically reassign priorities so the given ID order maps to ascending priorities (0..n-1).

Query parameters

  • limit
    integer
  • offset
    integer

Request parameters

  • ordered_ids
    array

Response


Example request

POST /api/projects/:project_id/tracing/retention_rules/reorder
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/retention_rules/reorder/\
-d ordered_ids="array"

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}

Create tracing retention rules suggest name

Suggest a human-readable name for a retention rule from its retention tier and filter group. Used by the create form as an auto-suggest; nothing is persisted. Returns an empty name when a suggestion can't be generated.

Request parameters

  • retention_days
    integer
  • filter_group

Response


Example request

POST /api/projects/:project_id/tracing/retention_rules/suggest_name
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/retention_rules/suggest_name/\
-d retention_days="integer",\
-d filter_group=undefined

Example response

Status 200
RESPONSE
{
"name": "string"
}

Create tracing spans aggregate

Required API key scopes

tracing:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/tracing/spans/aggregate
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/aggregate/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"service_name": "string",
"name": "string",
"count": 0,
"total_duration_nano": 0.1,
"avg_duration_nano": 0.1,
"p50_duration_nano": 0.1,
"p95_duration_nano": 0.1,
"p99_duration_nano": 0.1,
"p999_duration_nano": 0.1,
"error_count": 0,
"sessions": 0,
"users": 0,
"spans_with_session_id": 0,
"spans_with_distinct_id": 0
}
],
"compare": [
{
"service_name": "string",
"name": "string",
"count": 0,
"total_duration_nano": 0.1,
"avg_duration_nano": 0.1,
"p50_duration_nano": 0.1,
"p95_duration_nano": 0.1,
"p99_duration_nano": 0.1,
"p999_duration_nano": 0.1,
"error_count": 0,
"sessions": 0,
"users": 0,
"spans_with_session_id": 0,
"spans_with_distinct_id": 0
}
],
"has_more": true,
"next_offset": 0
}

Create tracing spans attribute breakdown

Required API key scopes

tracing:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/tracing/spans/attribute-breakdown
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/attribute-breakdown/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"value": "string",
"count": 0,
"error_count": 0,
"p50_duration_nano": 0.1,
"p95_duration_nano": 0.1
}
],
"compare": [
{
"value": "string",
"count": 0,
"error_count": 0,
"p50_duration_nano": 0.1,
"p95_duration_nano": 0.1
}
]
}

Retrieve tracing spans attributes

Required API key scopes

tracing:read

Query parameters

  • attribute_type
    string
    One of: "span_attribute""span_resource_attribute"
  • limit
    integer
  • offset
    integer
  • search
    string
  • search_values
    boolean
    Default: false

Response


Example request

GET /api/projects/:project_id/tracing/spans/attributes
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/attributes/

Example response

Status 200
RESPONSE
{
"results": [
{
"name": "string",
"propertyFilterType": "string",
"matchedOn": "key",
"matchedValue": "string"
}
],
"count": 0
}

Create tracing spans count

Required API key scopes

tracing:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/tracing/spans/count
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/count/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"count": 0,
"traceCount": 0
}

Create tracing spans duration histogram

Required API key scopes

tracing:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/tracing/spans/duration-histogram
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/duration-histogram/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"bucket_ns": 0,
"service": "string",
"count": 0
}
]
}

Create tracing spans error counts

Count the exceptions the spans in view hit, by trace, by span and by session, for the span list's error badges.

A caller asks about the id kinds it has, and each kind is a separate lookup.

Required API key scopes

tracing:readerror_tracking:read

Request parameters

  • traceIds
    array
  • spanIds
    array
  • sessionIds
    array
  • dateFrom
    string
  • dateTo
    string

Response


Example request

POST /api/projects/:project_id/tracing/spans/error-counts
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/error-counts/\
-d dateFrom="string",\
-d dateTo="string"

Example response

Status 200
RESPONSE
{
"traceResults": [
{
"exceptions": 0,
"trace_id": "string"
}
],
"spanResults": [
{
"exceptions": 0,
"span_id": "string"
}
],
"sessionResults": [
{
"exceptions": 0,
"session_id": "string"
}
]
}

Retrieve tracing spans has spans

Required API key scopes

tracing:read

Response


Example request

GET /api/projects/:project_id/tracing/spans/has_spans
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/has_spans/

Example response

Status 200
RESPONSE
{
"hasSpans": true
}

Create tracing spans impact

Required API key scopes

tracing:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/tracing/spans/impact
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/impact/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"total": 0,
"spansWithSessionId": 0,
"sessions": 0,
"spansWithDistinctId": 0,
"users": 0,
"topSessions": [
{
"value": "string",
"count": 0
}
],
"topUsers": [
{
"value": "string",
"count": 0
}
]
}

Create tracing spans latency heatmap

Required API key scopes

tracing:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/tracing/spans/latency-heatmap
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/latency-heatmap/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"time": "string",
"bucket_ns": 0,
"count": 0
}
]
}

Create tracing spans query

Required API key scopes

tracing:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/tracing/spans/query
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/query/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"uuid": "string",
"trace_id": "string",
"span_id": "string",
"parent_span_id": "string",
"name": "string",
"kind": 0,
"service_name": "string",
"status_code": 0,
"timestamp": "2019-08-24T14:15:22Z",
"end_time": "2019-08-24T14:15:22Z",
"duration_nano": 0.1,
"is_root_span": true,
"matched_filter": 0,
"trace_start": "2019-08-24T14:15:22Z",
"trace_duration": 0.1,
"attributes": {
"property1": "string",
"property2": "string"
},
"resource_attributes": {
"property1": "string",
"property2": "string"
}
}
],
"hasMore": true,
"nextCursor": "string"
}

Retrieve tracing spans service names

Required API key scopes

tracing:read

Query parameters

  • dateRange
    string
  • search
    string

Response


Example request

GET /api/projects/:project_id/tracing/spans/service-names
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/service-names/

Example response

Status 200
RESPONSE
{
"results": [
{
"name": "string"
}
]
}

Create tracing spans sparkline

Required API key scopes

tracing:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/tracing/spans/sparkline
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tracing/spans/sparkline/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"time": "2019-08-24T14:15:22Z",
"service": "string",
"count": 0
}
]
}