Skip to content

fix(trace-explorer): Handle empty baseline cohort in ranked attributes API#106483

Merged
aliu39 merged 3 commits intomasterfrom
seer/fix-trace-explorer-empty-baseline
Jan 20, 2026
Merged

fix(trace-explorer): Handle empty baseline cohort in ranked attributes API#106483
aliu39 merged 3 commits intomasterfrom
seer/fix-trace-explorer-empty-baseline

Conversation

@seer-by-sentry
Copy link
Copy Markdown
Contributor

@seer-by-sentry seer-by-sentry Bot commented Jan 16, 2026

Surfaced from SENTRY-555Z, but does not directly address its root cause

The /api/0/organizations/{organization_id_or_slug}/trace-items/attributes/ranked/ endpoint was returning a 500 error when the calculated total_baseline was zero or negative.

This occurred because the downstream Seer service would encounter a ZeroDivisionError when attempting Laplace smoothing with a total_count of zero. The total_baseline in Sentry becomes zero when the "outlier" cohort query matches all or more spans than the "baseline" cohort query.

This change introduces an early return in the Sentry endpoint. If total_baseline <= 0, the endpoint now returns a 200 OK response with an empty rankedAttributes list. The response shape now consistently includes rankingInfo, cohort1Total, and cohort2Total even in this early return case, providing a more complete and predictable API response to the frontend.

This prevents 500 errors for users, provides a consistent API response, and avoids unnecessary calls to the Seer service when no meaningful comparison can be made.

closes AIML-2306: c.w. endpoint bug

@aliu39 aliu39 requested a review from a team January 16, 2026 23:31
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 16, 2026
@seer-by-sentry seer-by-sentry Bot force-pushed the seer/fix-trace-explorer-empty-baseline branch from b9fa5ba to 6f55e94 Compare January 16, 2026 23:42
@seer-by-sentry seer-by-sentry Bot changed the title fix(trace-explorer): Prevent 500 when trace item attributes baseline is empty fix(trace-explorer): Handle empty baseline cohort in attribute ranking Jan 16, 2026
@seer-by-sentry seer-by-sentry Bot force-pushed the seer/fix-trace-explorer-empty-baseline branch from 6f55e94 to a88e8da Compare January 16, 2026 23:45
@seer-by-sentry seer-by-sentry Bot changed the title fix(trace-explorer): Handle empty baseline cohort in attribute ranking fix(trace-explorer): Handle empty baseline cohort in ranked attributes API Jan 16, 2026
@linear
Copy link
Copy Markdown

linear Bot commented Jan 16, 2026

@aliu39 aliu39 marked this pull request as ready for review January 16, 2026 23:47
@aliu39 aliu39 requested review from a team as code owners January 16, 2026 23:47
@aliu39 aliu39 requested a review from a team January 16, 2026 23:48
@aliu39 aliu39 added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Jan 16, 2026
@github-actions github-actions Bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Jan 17, 2026
@aliu39 aliu39 requested a review from shruthilayaj January 20, 2026 17:18
@aliu39 aliu39 added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Jan 20, 2026
@aliu39 aliu39 enabled auto-merge (squash) January 20, 2026 19:13
@aliu39 aliu39 merged commit 879657d into master Jan 20, 2026
69 of 70 checks passed
@aliu39 aliu39 deleted the seer/fix-trace-explorer-empty-baseline branch January 20, 2026 19:20
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants