Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sentry/api/bases/organization_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 9 additions & 5 deletions src/sentry/api/endpoints/organization_profiling_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def get(self, request: Request, organization: Organization) -> Response:
"package",
"function",
"count()",
"examples()",
],
query=data.get("query"),
snuba_params=snuba_params,
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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"),
)
Expand Down Expand Up @@ -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(
{
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand Down
Loading