Skip to content

Commit

Permalink
feat(discover): Query specific datasets in events-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
narsaynorath committed Jul 27, 2024
1 parent 00c99df commit a6e4e6b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/sentry/api/endpoints/organization_events_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
metrics_performance,
spans_indexed,
spans_metrics,
transactions,
)
from sentry.snuba.metrics.extraction import MetricSpecType
from sentry.snuba.referrer import Referrer
Expand Down Expand Up @@ -348,8 +349,7 @@ def fn(
# This is essentially cached behaviour and we skip the check
split_query = query
if widget.discover_widget_split == DashboardWidgetTypes.ERROR_EVENTS:
split_dataset = discover
split_query = f"({query}) AND !event.type:transaction"
split_dataset = errors
elif widget.discover_widget_split == DashboardWidgetTypes.TRANSACTION_LIKE:
# We can't add event.type:transaction for now because of on-demand.
split_dataset = scoped_dataset
Expand All @@ -368,13 +368,12 @@ def fn(
)

# Widget has not split the discover dataset yet, so we need to check if there are errors etc.
errors_only_query = f"({query}) AND !event.type:transaction"
error_results = None
try:
error_results = _get_event_stats(
discover,
errors,
query_columns,
errors_only_query,
query,
params,
rollup,
zerofill_results,
Expand Down Expand Up @@ -411,11 +410,10 @@ def fn(
if has_errors and has_other_data and not using_metrics:
# In the case that the original request was not using the metrics dataset, we cannot be certain that other data is solely transactions.
sentry_sdk.set_tag("third_split_query", True)
transactions_only_query = f"({query}) AND event.type:transaction"
transaction_results = _get_event_stats(
discover,
transactions,
query_columns,
transactions_only_query,
query,
params,
rollup,
zerofill_results,
Expand Down

0 comments on commit a6e4e6b

Please sign in to comment.