Skip to content

Commit e018458

Browse files
Revert "feat: Make extrapolation mode an enum (#103071)"
This reverts commit a093a68. Co-authored-by: shruthilayaj <[email protected]>
1 parent 8e05121 commit e018458

File tree

12 files changed

+37
-205
lines changed

12 files changed

+37
-205
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ dependencies = [
8383
"sentry-forked-email-reply-parser>=0.5.12.post1",
8484
"sentry-kafka-schemas>=2.1.15",
8585
"sentry-ophio>=1.1.3",
86-
"sentry-protos>=0.4.3",
86+
"sentry-protos>=0.4.2",
8787
"sentry-redis-tools>=0.5.0",
8888
"sentry-relay>=0.9.19",
8989
"sentry-sdk[http2]>=2.43.0",

src/sentry/api/endpoints/organization_events.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
from sentry.apidocs.parameters import GlobalParams, OrganizationParams, VisibilityParams
2626
from sentry.apidocs.utils import inline_sentry_response_serializer
2727
from sentry.discover.models import DiscoverSavedQuery, DiscoverSavedQueryTypes
28-
from sentry.exceptions import InvalidParams, InvalidSearchQuery
28+
from sentry.exceptions import InvalidParams
2929
from sentry.models.dashboard_widget import DashboardWidget, DashboardWidgetTypes
3030
from sentry.models.organization import Organization
3131
from sentry.ratelimits.config import RateLimitConfig
32-
from sentry.search.eap.constants import EXTRAPOLATION_MODE_MAP
3332
from sentry.search.eap.trace_metrics.config import (
3433
TraceMetricsSearchResolverConfig,
3534
get_trace_metric_from_request,
@@ -518,28 +517,18 @@ def get_rpc_config():
518517
request.GET.get("disableAggregateExtrapolation", "0") == "1"
519518
)
520519

521-
requested_mode = request.GET.get("extrapolationMode", None)
522-
if requested_mode is not None and requested_mode not in EXTRAPOLATION_MODE_MAP:
523-
raise InvalidSearchQuery(f"Unknown extrapolation mode: {requested_mode}")
524-
525-
extrapolation_mode = (
526-
EXTRAPOLATION_MODE_MAP[requested_mode] if requested_mode else None
527-
)
528-
529520
if scoped_dataset == Spans:
530521
return SearchResolverConfig(
531522
auto_fields=True,
532523
use_aggregate_conditions=use_aggregate_conditions,
533524
fields_acl=FieldsACL(functions={"time_spent_percentage"}),
534525
disable_aggregate_extrapolation=disable_aggregate_extrapolation,
535-
extrapolation_mode=extrapolation_mode,
536526
)
537527
elif scoped_dataset == OurLogs:
538528
# ourlogs doesn't have use aggregate conditions
539529
return SearchResolverConfig(
540530
use_aggregate_conditions=False,
541531
disable_aggregate_extrapolation=disable_aggregate_extrapolation,
542-
extrapolation_mode=extrapolation_mode,
543532
)
544533
elif scoped_dataset == TraceMetrics:
545534
# tracemetrics uses aggregate conditions
@@ -552,28 +541,24 @@ def get_rpc_config():
552541
use_aggregate_conditions=use_aggregate_conditions,
553542
auto_fields=True,
554543
disable_aggregate_extrapolation=disable_aggregate_extrapolation,
555-
extrapolation_mode=extrapolation_mode,
556544
)
557545
elif scoped_dataset == ProfileFunctions:
558546
# profile_functions uses aggregate conditions
559547
return SearchResolverConfig(
560548
use_aggregate_conditions=use_aggregate_conditions,
561549
auto_fields=True,
562550
disable_aggregate_extrapolation=disable_aggregate_extrapolation,
563-
extrapolation_mode=extrapolation_mode,
564551
)
565552
elif scoped_dataset == uptime_results.UptimeResults:
566553
return SearchResolverConfig(
567554
use_aggregate_conditions=use_aggregate_conditions,
568555
auto_fields=True,
569556
disable_aggregate_extrapolation=disable_aggregate_extrapolation,
570-
extrapolation_mode=extrapolation_mode,
571557
)
572558
else:
573559
return SearchResolverConfig(
574560
use_aggregate_conditions=use_aggregate_conditions,
575561
disable_aggregate_extrapolation=disable_aggregate_extrapolation,
576-
extrapolation_mode=extrapolation_mode,
577562
)
578563

579564
if snuba_params.sampling_mode == "HIGHEST_ACCURACY_FLEX_TIME":

src/sentry/api/endpoints/organization_events_stats.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
transform_query_columns_for_error_upsampling,
1818
)
1919
from sentry.constants import MAX_TOP_EVENTS
20-
from sentry.exceptions import InvalidSearchQuery
2120
from sentry.models.dashboard_widget import DashboardWidget, DashboardWidgetTypes
2221
from sentry.models.organization import Organization
23-
from sentry.search.eap.constants import EXTRAPOLATION_MODE_MAP
2422
from sentry.search.eap.trace_metrics.config import (
2523
TraceMetricsSearchResolverConfig,
2624
get_trace_metric_from_request,
@@ -245,14 +243,6 @@ def get_rpc_config():
245243
if scoped_dataset not in RPC_DATASETS:
246244
raise NotImplementedError
247245

248-
requested_mode = request.GET.get("extrapolationMode", None)
249-
if requested_mode is not None and requested_mode not in EXTRAPOLATION_MODE_MAP:
250-
raise InvalidSearchQuery(f"Unknown extrapolation mode: {requested_mode}")
251-
252-
extrapolation_mode = (
253-
EXTRAPOLATION_MODE_MAP[requested_mode] if requested_mode else None
254-
)
255-
256246
if scoped_dataset == TraceMetrics:
257247
# tracemetrics uses aggregate conditions
258248
metric_name, metric_type, metric_unit = get_trace_metric_from_request(request)
@@ -267,7 +257,6 @@ def get_rpc_config():
267257
"disableAggregateExtrapolation", "0"
268258
)
269259
== "1",
270-
extrapolation_mode=extrapolation_mode,
271260
)
272261

273262
return SearchResolverConfig(
@@ -277,7 +266,6 @@ def get_rpc_config():
277266
"disableAggregateExtrapolation", "0"
278267
)
279268
== "1",
280-
extrapolation_mode=extrapolation_mode,
281269
)
282270

283271
if top_events > 0:

src/sentry/api/endpoints/organization_events_timeseries.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
)
2323
from sentry.api.utils import handle_query_errors
2424
from sentry.constants import MAX_TOP_EVENTS
25-
from sentry.exceptions import InvalidSearchQuery
2625
from sentry.models.organization import Organization
27-
from sentry.search.eap.constants import EXTRAPOLATION_MODE_MAP
2826
from sentry.search.eap.trace_metrics.config import (
2927
TraceMetricsSearchResolverConfig,
3028
get_trace_metric_from_request,
@@ -224,12 +222,6 @@ def get_rpc_config():
224222
if dataset not in RPC_DATASETS:
225223
raise NotImplementedError
226224

227-
requested_mode = request.GET.get("extrapolationMode", None)
228-
if requested_mode is not None and requested_mode not in EXTRAPOLATION_MODE_MAP:
229-
raise InvalidSearchQuery(f"Unknown extrapolation mode: {requested_mode}")
230-
231-
extrapolation_mode = EXTRAPOLATION_MODE_MAP[requested_mode] if requested_mode else None
232-
233225
if dataset == TraceMetrics:
234226
# tracemetrics uses aggregate conditions
235227
metric_name, metric_type, metric_unit = get_trace_metric_from_request(request)
@@ -243,7 +235,6 @@ def get_rpc_config():
243235
"disableAggregateExtrapolation", "0"
244236
)
245237
== "1",
246-
extrapolation_mode=extrapolation_mode,
247238
)
248239

249240
return SearchResolverConfig(
@@ -253,7 +244,6 @@ def get_rpc_config():
253244
"disableAggregateExtrapolation", "0"
254245
)
255246
== "1",
256-
extrapolation_mode=extrapolation_mode,
257247
)
258248

259249
if top_events > 0:

src/sentry/search/eap/columns.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from sentry.api.event_search import SearchFilter
2323
from sentry.exceptions import InvalidSearchQuery
2424
from sentry.search.eap import constants
25-
from sentry.search.eap.extrapolation_mode import resolve_extrapolation_mode
2625
from sentry.search.eap.types import EAPResponse, MetricType, SearchResolverConfig
2726
from 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):
235239
class 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,

src/sentry/search/eap/constants.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sentry_protos.snuba.v1.downsampled_storage_pb2 import DownsampledStorageConfig
44
from sentry_protos.snuba.v1.endpoint_trace_item_table_pb2 import AggregationComparisonFilter, Column
55
from sentry_protos.snuba.v1.request_common_pb2 import TraceItemType
6-
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import AttributeKey, ExtrapolationMode
6+
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import AttributeKey
77
from sentry_protos.snuba.v1.trace_item_filter_pb2 import ComparisonFilter
88

99
from sentry.search.eap.types import SupportedTraceItemType
@@ -50,13 +50,6 @@
5050
"<=": AggregationComparisonFilter.OP_LESS_THAN_OR_EQUALS,
5151
}
5252

53-
EXTRAPOLATION_MODE_MAP = {
54-
"sampleWeighted": ExtrapolationMode.EXTRAPOLATION_MODE_SAMPLE_WEIGHTED,
55-
"serverOnly": ExtrapolationMode.EXTRAPOLATION_MODE_SERVER_ONLY,
56-
"unspecified": ExtrapolationMode.EXTRAPOLATION_MODE_UNSPECIFIED,
57-
"none": ExtrapolationMode.EXTRAPOLATION_MODE_NONE,
58-
}
59-
6053
SearchType = (
6154
SizeUnit
6255
| DurationUnit

src/sentry/search/eap/extrapolation_mode.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/sentry/search/eap/spans/aggregates.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import (
44
AttributeKey,
55
AttributeValue,
6-
ExtrapolationMode,
76
Function,
87
StrArray,
98
)
@@ -452,7 +451,7 @@ def resolve_bounded_sample(args: ResolvedArguments) -> tuple[AttributeKey, Trace
452451
],
453452
aggregate_resolver=resolve_bounded_sample,
454453
processor=lambda x: x > 0,
455-
extrapolation_mode_override=ExtrapolationMode.EXTRAPOLATION_MODE_NONE,
454+
extrapolation=False,
456455
),
457456
}
458457

@@ -509,7 +508,7 @@ def resolve_bounded_sample(args: ResolvedArguments) -> tuple[AttributeKey, Trace
509508
default_arg="span.duration",
510509
)
511510
],
512-
extrapolation_mode_override=ExtrapolationMode.EXTRAPOLATION_MODE_NONE,
511+
extrapolation=False,
513512
),
514513
"count": AggregateDefinition(
515514
internal_function=Function.FUNCTION_COUNT,
@@ -550,7 +549,7 @@ def resolve_bounded_sample(args: ResolvedArguments) -> tuple[AttributeKey, Trace
550549
default_arg="span.duration",
551550
)
552551
],
553-
extrapolation_mode_override=ExtrapolationMode.EXTRAPOLATION_MODE_NONE,
552+
extrapolation=False,
554553
),
555554
"p50": AggregateDefinition(
556555
internal_function=Function.FUNCTION_P50,
@@ -586,7 +585,7 @@ def resolve_bounded_sample(args: ResolvedArguments) -> tuple[AttributeKey, Trace
586585
default_arg="span.duration",
587586
)
588587
],
589-
extrapolation_mode_override=ExtrapolationMode.EXTRAPOLATION_MODE_NONE,
588+
extrapolation=False,
590589
),
591590
"p75": AggregateDefinition(
592591
internal_function=Function.FUNCTION_P75,

src/sentry/search/eap/types.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TYPE_CHECKING, Literal, NotRequired, TypedDict
44

55
from sentry_protos.snuba.v1.request_common_pb2 import PageToken
6-
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import ExtrapolationMode, Reliability
6+
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import Reliability
77
from sentry_protos.snuba.v1.trace_item_filter_pb2 import TraceItemFilter
88

99
from sentry.search.events.types import EventsResponse
@@ -31,7 +31,6 @@ class SearchResolverConfig:
3131
fields_acl: FieldsACL = field(default_factory=lambda: FieldsACL())
3232
# If set to True, do not extrapolate any values regardless of individual aggregate settings
3333
disable_aggregate_extrapolation: bool = False
34-
extrapolation_mode: ExtrapolationMode.ValueType | None = None
3534
# Whether to set the timestamp granularities to stable buckets
3635
stable_timestamp_quantization: bool = True
3736

0 commit comments

Comments
 (0)