Skip to content

Commit 72a7dcb

Browse files
authored
feat(profiling): Support continuous profiling in function trends (#80430)
In order to support continuous profiling functions, introduce a new list called `examples` that the frontend needs to migrate to that will contain the meta data to link to either a transaction profile or a continuous profile.
1 parent 24c63bb commit 72a7dcb

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/sentry/api/bases/organization_events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,15 @@ def get_event_stats_data(
420420
allow_partial_buckets: bool = False,
421421
zerofill_results: bool = True,
422422
comparison_delta: timedelta | None = None,
423-
additional_query_column: str | None = None,
423+
additional_query_columns: list[str] | None = None,
424424
dataset: Any | None = None,
425425
) -> dict[str, Any]:
426426
with handle_query_errors():
427427
with sentry_sdk.start_span(op="discover.endpoint", name="base.stats_query_creation"):
428428
_columns = [query_column]
429429
# temporary change to make topN query work for multi-axes requests
430-
if additional_query_column is not None:
431-
_columns.append(additional_query_column)
430+
if additional_query_columns is not None:
431+
_columns.extend(additional_query_columns)
432432

433433
columns = request.GET.getlist("yAxis", _columns)
434434

src/sentry/api/endpoints/organization_profiling_functions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def get(self, request: Request, organization: Organization) -> Response:
100100
"package",
101101
"function",
102102
"count()",
103-
"examples()",
104103
],
105104
query=data.get("query"),
106105
snuba_params=snuba_params,
@@ -135,7 +134,7 @@ def get_event_stats(
135134
# It's possible to override the columns via
136135
# the `yAxis` qs. So we explicitly ignore the
137136
# columns, and hard code in the columns we want.
138-
timeseries_columns=[data["function"], "examples()"],
137+
timeseries_columns=[data["function"], "examples()", "all_examples()"],
139138
config=QueryBuilderConfig(
140139
skip_tag_resolution=True,
141140
),
@@ -196,7 +195,7 @@ def get_trends_data(stats_data) -> list[BreakpointData]:
196195
get_event_stats,
197196
top_events=FUNCTIONS_PER_QUERY,
198197
query_column=data["function"],
199-
additional_query_column="examples()",
198+
additional_query_columns=["examples()", "all_examples()"],
200199
snuba_params=snuba_params,
201200
query=data.get("query"),
202201
)
@@ -244,11 +243,16 @@ def get_stats_data_for_trending_events(results):
244243
key = f"{result['project']},{result['transaction']}"
245244
formatted_result = {
246245
"stats": stats_data[key][data["function"]],
247-
"worst": [
246+
"worst": [ # deprecated, migrate to `examples`
248247
(ts, data[0]["count"][0])
249248
for ts, data in stats_data[key]["examples()"]["data"]
250249
if data[0]["count"] # filter out entries without an example
251250
],
251+
"examples": [
252+
(ts, data[0]["count"][0])
253+
for ts, data in stats_data[key]["all_examples()"]["data"]
254+
if data[0]["count"] # filter out entries without an example
255+
],
252256
}
253257
formatted_result.update(
254258
{
@@ -269,7 +273,7 @@ def get_stats_data_for_trending_events(results):
269273
formatted_result.update(
270274
{
271275
k: functions[key][k]
272-
for k in ["fingerprint", "package", "function", "count()", "examples()"]
276+
for k in ["fingerprint", "package", "function", "count()"]
273277
}
274278
)
275279
formatted_results.append(formatted_result)

tests/sentry/api/endpoints/test_organization_profiling_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def test_regression(self, mock_detect_breakpoints):
225225
assert trend_percentages == [10.0, 5.0]
226226
for data in results:
227227
assert isinstance(data["worst"], list)
228+
assert isinstance(data["examples"], list)
228229

229230
@mock.patch("sentry.api.endpoints.organization_profiling_functions.detect_breakpoints")
230231
def test_improvement(self, mock_detect_breakpoints):
@@ -310,6 +311,7 @@ def test_improvement(self, mock_detect_breakpoints):
310311
assert trend_percentages == [0.1, 0.2]
311312
for data in results:
312313
assert isinstance(data["worst"], list)
314+
assert isinstance(data["examples"], list)
313315

314316

315317
def test_get_rollup_from_range_max_buckets():

0 commit comments

Comments
 (0)