2222from sentry .api .event_search import SearchFilter
2323from sentry .exceptions import InvalidSearchQuery
2424from sentry .search .eap import constants
25- from sentry .search .eap .types import EAPResponse
25+ from sentry .search .eap .types import EAPResponse , SearchResolverConfig
2626from sentry .search .events .types import SnubaParams
2727
2828ResolvedArgument : TypeAlias = AttributeKey | str | int | float
@@ -33,6 +33,7 @@ class ResolverSettings(TypedDict):
3333 extrapolation_mode : ExtrapolationMode .ValueType
3434 snuba_params : SnubaParams
3535 query_result_cache : dict [str , EAPResponse ]
36+ search_config : SearchResolverConfig
3637
3738
3839@dataclass (frozen = True , kw_only = True )
@@ -298,7 +299,7 @@ def resolve(
298299 resolved_arguments : ResolvedArguments ,
299300 snuba_params : SnubaParams ,
300301 query_result_cache : dict [str , EAPResponse ],
301- extrapolation_override : bool = False ,
302+ search_config : SearchResolverConfig ,
302303 ) -> ResolvedFormula | ResolvedAggregate | ResolvedConditionalAggregate :
303304 raise NotImplementedError ()
304305
@@ -319,7 +320,7 @@ def resolve(
319320 resolved_arguments : ResolvedArguments ,
320321 snuba_params : SnubaParams ,
321322 query_result_cache : dict [str , EAPResponse ],
322- extrapolation_override : bool = False ,
323+ search_config : SearchResolverConfig ,
323324 ) -> ResolvedAggregate :
324325 if len (resolved_arguments ) > 1 :
325326 raise InvalidSearchQuery (
@@ -341,7 +342,9 @@ def resolve(
341342 search_type = search_type ,
342343 internal_type = self .internal_type ,
343344 processor = self .processor ,
344- extrapolation = self .extrapolation if not extrapolation_override else False ,
345+ extrapolation = (
346+ self .extrapolation if not search_config .disable_aggregate_extrapolation else False
347+ ),
345348 argument = resolved_attribute ,
346349 )
347350
@@ -367,7 +370,7 @@ def resolve(
367370 resolved_arguments : ResolvedArguments ,
368371 snuba_params : SnubaParams ,
369372 query_result_cache : dict [str , EAPResponse ],
370- extrapolation_override : bool = False ,
373+ search_config : SearchResolverConfig ,
371374 ) -> ResolvedConditionalAggregate :
372375 key , aggregate_filter = self .aggregate_resolver (resolved_arguments )
373376 return ResolvedConditionalAggregate (
@@ -378,7 +381,9 @@ def resolve(
378381 filter = aggregate_filter ,
379382 key = key ,
380383 processor = self .processor ,
381- extrapolation = self .extrapolation if not extrapolation_override else False ,
384+ extrapolation = (
385+ self .extrapolation if not search_config .disable_aggregate_extrapolation else False
386+ ),
382387 )
383388
384389
@@ -401,16 +406,17 @@ def resolve(
401406 resolved_arguments : list [AttributeKey | Any ],
402407 snuba_params : SnubaParams ,
403408 query_result_cache : dict [str , EAPResponse ],
404- extrapolation_override : bool = False ,
409+ search_config : SearchResolverConfig ,
405410 ) -> ResolvedFormula :
406411 resolver_settings = ResolverSettings (
407412 extrapolation_mode = (
408413 ExtrapolationMode .EXTRAPOLATION_MODE_SAMPLE_WEIGHTED
409- if self .extrapolation and not extrapolation_override
414+ if self .extrapolation and not search_config . disable_aggregate_extrapolation
410415 else ExtrapolationMode .EXTRAPOLATION_MODE_NONE
411416 ),
412417 snuba_params = snuba_params ,
413418 query_result_cache = query_result_cache ,
419+ search_config = search_config ,
414420 )
415421
416422 return ResolvedFormula (
0 commit comments