2222from sentry .api .event_search import SearchFilter
2323from sentry .exceptions import InvalidSearchQuery
2424from sentry .search .eap import constants
25- from sentry .search .eap .extrapolation_mode import resolve_extrapolation_mode
2625from sentry .search .eap .types import EAPResponse , MetricType , SearchResolverConfig
2726from sentry .search .events .types import SnubaParams
2827
@@ -208,7 +207,8 @@ class ResolvedAggregate(ResolvedFunction):
208207
209208 # The internal rpc alias for this column
210209 internal_name : Function .ValueType
211- extrapolation_mode : ExtrapolationMode .ValueType
210+ # Whether to enable extrapolation
211+ extrapolation : bool = True
212212 is_aggregate : bool = field (default = True , init = False )
213213 # Only for aggregates, we only support functions with 1 argument right now
214214 argument : AttributeKey | None = None
@@ -220,7 +220,11 @@ def proto_definition(self) -> AttributeAggregation:
220220 aggregate = self .internal_name ,
221221 key = self .argument ,
222222 label = self .public_alias ,
223- extrapolation_mode = self .extrapolation_mode ,
223+ extrapolation_mode = (
224+ ExtrapolationMode .EXTRAPOLATION_MODE_SAMPLE_WEIGHTED
225+ if self .extrapolation
226+ else ExtrapolationMode .EXTRAPOLATION_MODE_NONE
227+ ),
224228 )
225229
226230
@@ -235,7 +239,8 @@ class ResolvedTraceMetricAggregate(ResolvedAggregate):
235239class ResolvedConditionalAggregate (ResolvedFunction ):
236240 # The internal rpc alias for this column
237241 internal_name : Function .ValueType
238- extrapolation_mode : ExtrapolationMode .ValueType
242+ # Whether to enable extrapolation
243+ extrapolation : bool = True
239244 # The condition to filter on
240245 filter : TraceItemFilter
241246 # The attribute to conditionally aggregate on
@@ -251,7 +256,11 @@ def proto_definition(self) -> AttributeConditionalAggregation:
251256 key = self .key ,
252257 filter = self .filter ,
253258 label = self .public_alias ,
254- extrapolation_mode = self .extrapolation_mode ,
259+ extrapolation_mode = (
260+ ExtrapolationMode .EXTRAPOLATION_MODE_SAMPLE_WEIGHTED
261+ if self .extrapolation
262+ else ExtrapolationMode .EXTRAPOLATION_MODE_NONE
263+ ),
255264 )
256265
257266
@@ -284,8 +293,8 @@ class FunctionDefinition:
284293 infer_search_type_from_arguments : bool = True
285294 # The internal rpc type for this function, optional as it can mostly be inferred from search_type
286295 internal_type : AttributeKey .Type .ValueType | None = None
287- # Extrapolation mode to be used
288- extrapolation_mode_override : ExtrapolationMode . ValueType | None = None
296+ # Whether to request extrapolation or not, should be true for all functions except for _sample functions for debugging
297+ extrapolation : bool = True
289298 # Processor is the function run in the post process step to transform a row into the final result
290299 processor : Callable [[Any ], Any ] | None = None
291300 # if a function is private, assume it can't be used unless it's provided in `SearchResolverConfig.functions_acl`
@@ -347,8 +356,8 @@ def resolve(
347356 search_type = search_type ,
348357 internal_type = self .internal_type ,
349358 processor = self .processor ,
350- extrapolation_mode = resolve_extrapolation_mode (
351- search_config , self .extrapolation_mode_override
359+ extrapolation = (
360+ self .extrapolation if not search_config . disable_aggregate_extrapolation else False
352361 ),
353362 argument = resolved_attribute ,
354363 )
@@ -387,8 +396,8 @@ def resolve(
387396 search_type = search_type ,
388397 internal_type = self .internal_type ,
389398 processor = self .processor ,
390- extrapolation_mode = resolve_extrapolation_mode (
391- search_config , self .extrapolation_mode_override
399+ extrapolation = (
400+ self .extrapolation if not search_config . disable_aggregate_extrapolation else False
392401 ),
393402 argument = resolved_attribute ,
394403 metric_name = metric_name ,
@@ -429,8 +438,8 @@ def resolve(
429438 filter = aggregate_filter ,
430439 key = key ,
431440 processor = self .processor ,
432- extrapolation_mode = resolve_extrapolation_mode (
433- search_config , self .extrapolation_mode_override
441+ extrapolation = (
442+ self .extrapolation if not search_config . disable_aggregate_extrapolation else False
434443 ),
435444 )
436445
@@ -457,8 +466,10 @@ def resolve(
457466 search_config : SearchResolverConfig ,
458467 ) -> ResolvedFormula :
459468 resolver_settings = ResolverSettings (
460- extrapolation_mode = resolve_extrapolation_mode (
461- search_config , self .extrapolation_mode_override
469+ extrapolation_mode = (
470+ ExtrapolationMode .EXTRAPOLATION_MODE_SAMPLE_WEIGHTED
471+ if self .extrapolation and not search_config .disable_aggregate_extrapolation
472+ else ExtrapolationMode .EXTRAPOLATION_MODE_NONE
462473 ),
463474 snuba_params = snuba_params ,
464475 query_result_cache = query_result_cache ,
0 commit comments