---
title: "Rank operations by latency, volume, or inconsistency."
method: GET
path: "/otel/span-stats"
tags: ["Traces"]
---

# Rank operations by latency, volume, or inconsistency.

`GET /otel/span-stats`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/otel/span-stats`
- Auth: HTTP bearer

Groups spans by `(project, service, span name)` over a bounded window and
returns count, error rate, total/min/max/avg/stddev duration, p50/p95/p99,
and two variability ratios per operation. Sorting is what makes it useful:

- `sort_by=total_time` (default) — where the wall-clock actually goes.
- `sort_by=p95` / `p99` — what users actually feel.
- `sort_by=variability` or `tail_ratio` — operations whose *spread* is the
  problem: the ones that take 40ms most of the time and 4s the rest.
- `span_name=payments.charge` — the worst this one operation ever got, in
  `max_duration_ms`.

Pair the variability sorts with `min_count` — a ratio computed from three
samples is noise, and without a floor it outranks every real signal.

Two bounds are enforced rather than clamped, so a result never claims to
cover more than it does: at most 50 projects, and a window no wider than
31 days. Both return 400. Unlike the trace list this report has no early
exit — it aggregates every span in the window before it can rank anything.

## Query parameters

- `project_id` integer
- `project_ids` string
- `start_time` string
- `end_time` string
- `service_name` string
- `span_name` string
- `name_pattern` string
- `kind` string
- `status` string
- `environment_id` integer
- `deployment_id` integer
- `attributes` string
- `min_duration_ms` number, double
- `min_count` integer
- `sort_by` string
- `sort_order` string
- `limit` integer
- `offset` integer
- `apdex_threshold_ms` number, double

## Response `200`

Per-operation latency statistics

- SpanStatsResponse: Response for `GET /otel/span-stats`.
  - `data` SpanStats[], required
    - `apdex` number, double, nullable: Apdex for `apdex_threshold_ms`: `(satisfied + tolerating / 2) / count`, from 0 (everyone frustrated) to 1 (everyone satisfied). `None` when the query asked for no score.
    - `apdex_threshold_ms` number, double, nullable: The threshold `T` the score used, in milliseconds.
    - `avg_duration_ms` number, double, required
    - `coefficient_of_variation` number, double, required: `stddev / avg`, or `0` when `avg` is zero.
    - `count` integer, required: Number of spans aggregated.
    - `error_count` integer, required
    - `error_rate` number, double, required: `error_count / count`, in `[0, 1]`.
    - `frustrated_count` integer, nullable: Spans over `4T`.
    - `kind` 'UNSPECIFIED' | 'INTERNAL' | 'SERVER' | 'CLIENT' | 'PRODUCER' | 'CONSUMER', required: The most common span kind for this operation.
    - `last_seen` string, date-time, required: Start time of the most recent span in this group.
    - `max_duration_ms` number, double, required
    - `min_duration_ms` number, double, required
    - `p50_duration_ms` number, double, required
    - `p95_duration_ms` number, double, required
    - `p99_duration_ms` number, double, required
    - `project_id` integer, required
    - `satisfied_count` integer, nullable: Spans at or under `T`.
    - `service_name` string, required
    - `span_name` string, required: The span name, which is the operation identity: `GET /api/checkout`, `SELECT carts`, `payments.charge`.
    - `stddev_duration_ms` number, double, required: Sample standard deviation. `0` when the operation has a single sample.
    - `tail_ratio` number, double, required: `p99 / p50`, or `0` when `p50` is zero.
    - `tolerating_count` integer, nullable: Spans over `T` and at or under `4T`.
    - `total_duration_ms` number, double, required: `SUM(duration_ms)` — total wall-clock attributable to this operation.
  - `end_time` string, date-time, required
  - `start_time` string, date-time, required: The window actually aggregated, echoed back because it is defaulted server-side when the caller omits it.
  - `total` integer, required: Total number of distinct operations matching the filters, for pagination.

## Other responses

- `400`: Invalid query (no project, empty window)
- `401`: Unauthorized
- `403`: Insufficient permissions
- `500`: Internal server error

## Changes

- **2026-11-20** `89a5fa242f36`: 6 info
  - added the new optional `query` request parameter `apdex_threshold_ms`
  - added the optional property `data/items/apdex` to the response with the `200` status
  - added the optional property `data/items/apdex_threshold_ms` to the response with the `200` status
  - added the optional property `data/items/frustrated_count` to the response with the `200` status
  - …2 more
- **2026-11-09** `12896146b193`: 4 breaking
  - removed the required property `extensions` from the response with the `400` status
  - removed the required property `extensions` from the response with the `401` status
  - removed the required property `extensions` from the response with the `403` status
  - removed the required property `extensions` from the response with the `500` status
- **2026-10-05** `4b228ebed583`: 4 info
  - added the optional property `status` to the response with the `400` status
  - added the optional property `status` to the response with the `401` status
  - added the optional property `status` to the response with the `403` status
  - added the optional property `status` to the response with the `500` status
- …earlier changes not shown

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/otel/span-stats/get.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
