diff --git a/src/sentry/api/bases/organization_events.py b/src/sentry/api/bases/organization_events.py index a461391f22766f..330fe952ec3a61 100644 --- a/src/sentry/api/bases/organization_events.py +++ b/src/sentry/api/bases/organization_events.py @@ -420,15 +420,15 @@ def get_event_stats_data( allow_partial_buckets: bool = False, zerofill_results: bool = True, comparison_delta: timedelta | None = None, - additional_query_column: str | None = None, + additional_query_columns: list[str] | None = None, dataset: Any | None = None, ) -> dict[str, Any]: with handle_query_errors(): with sentry_sdk.start_span(op="discover.endpoint", name="base.stats_query_creation"): _columns = [query_column] # temporary change to make topN query work for multi-axes requests - if additional_query_column is not None: - _columns.append(additional_query_column) + if additional_query_columns is not None: + _columns.extend(additional_query_columns) columns = request.GET.getlist("yAxis", _columns) diff --git a/src/sentry/api/endpoints/organization_profiling_functions.py b/src/sentry/api/endpoints/organization_profiling_functions.py index 60504290081e42..3fd9e68acb0366 100644 --- a/src/sentry/api/endpoints/organization_profiling_functions.py +++ b/src/sentry/api/endpoints/organization_profiling_functions.py @@ -100,7 +100,6 @@ def get(self, request: Request, organization: Organization) -> Response: "package", "function", "count()", - "examples()", ], query=data.get("query"), snuba_params=snuba_params, @@ -135,7 +134,7 @@ def get_event_stats( # It's possible to override the columns via # the `yAxis` qs. So we explicitly ignore the # columns, and hard code in the columns we want. - timeseries_columns=[data["function"], "examples()"], + timeseries_columns=[data["function"], "examples()", "all_examples()"], config=QueryBuilderConfig( skip_tag_resolution=True, ), @@ -196,7 +195,7 @@ def get_trends_data(stats_data) -> list[BreakpointData]: get_event_stats, top_events=FUNCTIONS_PER_QUERY, query_column=data["function"], - additional_query_column="examples()", + additional_query_columns=["examples()", "all_examples()"], snuba_params=snuba_params, query=data.get("query"), ) @@ -244,11 +243,16 @@ def get_stats_data_for_trending_events(results): key = f"{result['project']},{result['transaction']}" formatted_result = { "stats": stats_data[key][data["function"]], - "worst": [ + "worst": [ # deprecated, migrate to `examples` (ts, data[0]["count"][0]) for ts, data in stats_data[key]["examples()"]["data"] if data[0]["count"] # filter out entries without an example ], + "examples": [ + (ts, data[0]["count"][0]) + for ts, data in stats_data[key]["all_examples()"]["data"] + if data[0]["count"] # filter out entries without an example + ], } formatted_result.update( { @@ -269,7 +273,7 @@ def get_stats_data_for_trending_events(results): formatted_result.update( { k: functions[key][k] - for k in ["fingerprint", "package", "function", "count()", "examples()"] + for k in ["fingerprint", "package", "function", "count()"] } ) formatted_results.append(formatted_result) diff --git a/tests/sentry/api/endpoints/test_organization_profiling_functions.py b/tests/sentry/api/endpoints/test_organization_profiling_functions.py index c25d3047ea5632..27dece81abaaf4 100644 --- a/tests/sentry/api/endpoints/test_organization_profiling_functions.py +++ b/tests/sentry/api/endpoints/test_organization_profiling_functions.py @@ -225,6 +225,7 @@ def test_regression(self, mock_detect_breakpoints): assert trend_percentages == [10.0, 5.0] for data in results: assert isinstance(data["worst"], list) + assert isinstance(data["examples"], list) @mock.patch("sentry.api.endpoints.organization_profiling_functions.detect_breakpoints") def test_improvement(self, mock_detect_breakpoints): @@ -310,6 +311,7 @@ def test_improvement(self, mock_detect_breakpoints): assert trend_percentages == [0.1, 0.2] for data in results: assert isinstance(data["worst"], list) + assert isinstance(data["examples"], list) def test_get_rollup_from_range_max_buckets():