Files
insights/products/tracing/mcp/prompts/apm-spans-duration-histogram.md
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

2.6 KiB

Trace counts per logarithmic duration bucket — the latency distribution of requests.

Returns one row per (duration bucket, service) pair:

  • bucket_ns — bucket floor in nanoseconds, on the 1-2-5 series (1ms, 2ms, 5ms, 10ms, 20ms, ...)
  • service — service name (top 10 services per bucket)
  • count — traces whose ROOT span duration falls in the bucket

Buckets count traces by their root span's duration (the request the user experienced), never child spans. Only non-empty buckets are returned.

Use to answer:

  • "What does the latency distribution look like — one population or bimodal?"
  • "How many requests took longer than 1 second?"
  • "Is the long tail a handful of outliers or a real second mode?"
  • "Which duration range should I filter on before pulling slow traces?"

For percentiles per operation (p50/p95), use apm-spans-aggregate. For counts over time, use apm-spans-sparkline.

All parameters must be nested inside a query object.

Parameters

All parameters go inside query.

query.dateRange

Date range. Defaults to the last hour.

  • date_from: Start of the range. ISO 8601 or relative: -1h, -6h, -1d, -7d.
  • date_to: End of the range. Same format. Omit or null for "now".

query.serviceNames

List of service names to restrict the histogram to. Use apm-services-list to discover services.

query.statusCodes

Filter by OTel span status codes (list of integers: 0 Unset, 1 OK, 2 Error) — not HTTP status codes. Use [2] to select error spans.

query.filterGroup

Property filters applied to the matched spans. Same filter shape and operators as query-apm-spans:

  • span — built-in span fields (trace_id, span_id, duration, name, kind, status_code, is_root_span)
  • span_attribute — span-level attributes
  • span_resource_attribute — resource-level attributes

Examples

Latency distribution for one service over the last day

{
  "query": {
    "serviceNames": ["api-gateway"],
    "dateRange": { "date_from": "-1d" }
  }
}

Distribution of error traces only

{
  "query": {
    "statusCodes": [2],
    "dateRange": { "date_from": "-6h" }
  }
}

Reminders

  • bucket_ns is nanoseconds: 1ms = 1,000,000; 1s = 1,000,000,000.
  • Counts are traces (one per root span), so they line up with request counts — not with apm-spans-count, which counts every span.
  • Buckets follow the 1-2-5 series; a trace of 3.5ms lands in the 2ms bucket (bucket floor).
  • To fetch the actual slow traces after spotting a tail, use query-apm-spans with a duration filter (nanoseconds) and orderBy: "duration".