Skip to content

feat(sentry): filter exceptions, traces and logs by project, environment and period - #352

Draft
tsan88 wants to merge 2 commits into
buggregator:masterfrom
tsan88:feat/sentry-api-filters
Draft

feat(sentry): filter exceptions, traces and logs by project, environment and period#352
tsan88 wants to merge 2 commits into
buggregator:masterfrom
tsan88:feat/sentry-api-filters

Conversation

@tsan88

@tsan88 tsan88 commented Sep 4, 2026

Copy link
Copy Markdown

Stacked on #351 — it contains that PR's commit as well (ParseWindow lives there). Please review after #351; I will rebase once it lands.

The sentry endpoints could only be narrowed by level, handled and trace_id.

project_id and environment are written for every error event but had no reader, so picking a project in the UI still listed every project's errors — including in the grouped view, which is the view that makes a shared instance usable. In the access log the frontend's request is literally exceptions?page=1&grouped=true, with no parameters at all.

There was also no way to narrow anything by time, so reaching an error from a particular hour meant paging through the whole list.

Changes

  • project and environment filters on /api/sentry/exceptions, both the chronological and the grouped view.
  • environment and release filters on /api/sentry/traces — columns that are written but were never read.
  • from / to / window on exceptions, traces, logs and counts. Comparison is done on the stored string format, which is lexicographically ordered, so the existing indexes on received_at, log_ts and start_ts still apply.
  • /api/sentry/counts respects the same project and period as the lists it labels. It counts sentry_transactions rather than sentry_traces: that is what the traces list shows, and it is the table that carries a timestamp to filter on.

Filters only apply when the parameters are present, so existing clients see no change.

Testing

go vet ./..., go test ./... and go build pass. Added TestAPIExceptionsFilters (project, environment, both, grouped, window) and TestAPICountsFollowFilters. Running in production on our instance.

tsan88 added 2 commits September 4, 2026 15:42
/api/events and /api/events/preview returned every event stored for the
requested type/project — FindOptions already had Limit and Offset, but the
handlers never filled them in. On a busy instance one preview request weighed
25.8 MB, and the frontend then filtered that in the browser.

Both endpoints now accept limit, offset/page, from, to and window (15m, 24h,
"7d"; "all" opts out of the configured default), and report what was applied in
the response meta so a client can tell a truncated response from an exhausted
one.

Defaults are deliberately conservative and non-breaking: 1000 events per
response, no time window. An operator can set ui.default_window (or
UI_DEFAULT_WINDOW) to also narrow lists by time.
…ent and period

The sentry endpoints could only be narrowed by level, handled and trace_id.
project_id and environment are written for every error event but had no reader,
so picking a project in the UI still listed every project's errors — including
in the grouped view, which is what makes it useful on a shared instance. There
was no way to narrow anything by time at all, so reaching a particular hour
meant paging through the entire list.

Adds:
  - project and environment filters on /api/sentry/exceptions (both the
    chronological and the grouped view);
  - environment and release filters on /api/sentry/traces (columns that were
    also written but never read);
  - from / to / window ("15m", "24h", "7d") on exceptions, traces, logs and
    counts.

/api/sentry/counts now respects the same project and period as the lists it
labels, and counts transactions rather than traces — that is what the traces
list shows and the table that carries a timestamp to filter on.

Filters only apply when the parameters are present, so existing clients see no
change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant