Skip to content

Commit e07e1b2

Browse files
authored
fix(timeseries): Fix handle top level metrics query params on timeseries (#102700)
The trace metrics dataset needs a `TraceMetricsSearchResolverConfig` instead.
1 parent 17572cb commit e07e1b2

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

src/sentry/api/endpoints/organization_events_timeseries.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
from sentry.api.utils import handle_query_errors
2424
from sentry.constants import MAX_TOP_EVENTS
2525
from sentry.models.organization import Organization
26+
from sentry.search.eap.trace_metrics.config import (
27+
TraceMetricsSearchResolverConfig,
28+
get_trace_metric_from_request,
29+
)
2630
from sentry.search.eap.types import SearchResolverConfig
2731
from sentry.search.events.types import SnubaParams
2832
from sentry.snuba import (
@@ -214,6 +218,33 @@ def get_event_stats(
214218
)
215219
)
216220

221+
def get_rpc_config():
222+
if dataset not in RPC_DATASETS:
223+
raise NotImplementedError
224+
225+
if dataset == TraceMetrics:
226+
# tracemetrics uses aggregate conditions
227+
metric_name, metric_type = get_trace_metric_from_request(request, organization)
228+
return TraceMetricsSearchResolverConfig(
229+
metric_name=metric_name,
230+
metric_type=metric_type,
231+
auto_fields=False,
232+
use_aggregate_conditions=True,
233+
disable_aggregate_extrapolation=request.GET.get(
234+
"disableAggregateExtrapolation", "0"
235+
)
236+
== "1",
237+
)
238+
239+
return SearchResolverConfig(
240+
auto_fields=False,
241+
use_aggregate_conditions=True,
242+
disable_aggregate_extrapolation=request.GET.get(
243+
"disableAggregateExtrapolation", "0"
244+
)
245+
== "1",
246+
)
247+
217248
if top_events > 0:
218249
raw_groupby = self.get_field_list(organization, request, param_name="groupBy")
219250
if len(raw_groupby) == 0:
@@ -230,14 +261,7 @@ def get_event_stats(
230261
limit=top_events,
231262
include_other=include_other,
232263
referrer=referrer,
233-
config=SearchResolverConfig(
234-
auto_fields=False,
235-
use_aggregate_conditions=True,
236-
disable_aggregate_extrapolation=request.GET.get(
237-
"disableAggregateExtrapolation", "0"
238-
)
239-
== "1",
240-
),
264+
config=get_rpc_config(),
241265
sampling_mode=snuba_params.sampling_mode,
242266
equations=self.get_equation_list(organization, request, param_name="groupBy"),
243267
)
@@ -266,14 +290,7 @@ def get_event_stats(
266290
query_string=query,
267291
y_axes=query_columns,
268292
referrer=referrer,
269-
config=SearchResolverConfig(
270-
auto_fields=False,
271-
use_aggregate_conditions=True,
272-
disable_aggregate_extrapolation=request.GET.get(
273-
"disableAggregateExtrapolation", "0"
274-
)
275-
== "1",
276-
),
293+
config=get_rpc_config(),
277294
sampling_mode=snuba_params.sampling_mode,
278295
comparison_delta=comparison_delta,
279296
)

0 commit comments

Comments
 (0)