Skip to content

feat(occurrences on eap): Implement double-read query for trace errors count#110251

Merged
shashjar merged 2 commits intomasterfrom
shashjar/implement-organization-trace-errors-query-occurrences-on-eap
Mar 10, 2026
Merged

feat(occurrences on eap): Implement double-read query for trace errors count#110251
shashjar merged 2 commits intomasterfrom
shashjar/implement-organization-trace-errors-query-occurrences-on-eap

Conversation

@shashjar
Copy link
Member

@shashjar shashjar commented Mar 9, 2026

Implements double reads of occurrences from EAP for the errors query in src/sentry/api/endpoints/organization_trace_meta.py.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 9, 2026
@shashjar shashjar requested a review from a team March 9, 2026 21:11
@shashjar shashjar marked this pull request as ready for review March 9, 2026 21:11
@shashjar shashjar requested review from a team as code owners March 9, 2026 21:11
@shashjar shashjar marked this pull request as draft March 9, 2026 21:24
@shashjar shashjar marked this pull request as ready for review March 9, 2026 21:39
Comment on lines +75 to +80
eap_count = count_occurrences_grouped_by_trace_ids(
snuba_params=snuba_params,
trace_ids=[trace_id],
referrer=Referrer.API_TRACE_VIEW_GET_EVENTS.value,
occurrence_category=OccurrenceCategory.ERROR,
).get(trace_id, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do we need grouped_by_trace_ids here? Couldn't we just run a regular Occurrences.run_table_query with query_string=f"trace_id:{trace_id}"? IMO that'd be clearer (since it wouldn't have the grouping postprocessing)... but happy either way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about that - I ended up going this way to be able to reuse the existing helper and allow the exception handling to just occur there rather than repeat it at the callsite. I would say the main downside is the dict return type (rather than raw int count), but I think I'm okay with that given it's still a relatively simple signature

@shashjar shashjar merged commit d1d20d2 into master Mar 10, 2026
55 checks passed
@shashjar shashjar deleted the shashjar/implement-organization-trace-errors-query-occurrences-on-eap branch March 10, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants