Skip to content

Commit 399eeec

Browse files
narsaynorathandrewshie-sentry
authored andcommitted
feat(eap): Default unspecified sampling mode to high accuracy (#90704)
Exposes `HIGHEST_ACCURACY` mode and uses it as the default if no sampling mode is defined. Eventually we want to lean into the fact that NORMAL mode is the default, but the frontend needs to be updated to make use of this. At the moment the frontend passes nothing for a high accuracy request, so we'll enforce the behaviour we expect here.
1 parent bf2d1b1 commit 399eeec

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

requirements-base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ rfc3986-validator>=0.1.1
6868
sentry-arroyo>=2.21.0
6969
sentry-kafka-schemas>=1.2.0
7070
sentry-ophio>=1.1.3
71-
sentry-protos==0.1.72
71+
sentry-protos==0.1.74
7272
sentry-redis-tools>=0.5.0
7373
sentry-relay>=0.9.8
7474
sentry-sdk[http2]>=2.25.1

requirements-dev-frozen.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ sentry-forked-djangorestframework-stubs==3.15.3.post1
189189
sentry-forked-email-reply-parser==0.5.12.post1
190190
sentry-kafka-schemas==1.2.0
191191
sentry-ophio==1.1.3
192-
sentry-protos==0.1.72
192+
sentry-protos==0.1.74
193193
sentry-redis-tools==0.5.0
194194
sentry-relay==0.9.8
195195
sentry-sdk==2.27.0

requirements-frozen.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ sentry-arroyo==2.21.0
127127
sentry-forked-email-reply-parser==0.5.12.post1
128128
sentry-kafka-schemas==1.2.0
129129
sentry-ophio==1.1.3
130-
sentry-protos==0.1.72
130+
sentry-protos==0.1.74
131131
sentry-redis-tools==0.5.0
132132
sentry-relay==0.9.8
133133
sentry-sdk==2.27.0

src/sentry/search/eap/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,5 @@
162162
"BEST_EFFORT": DownsampledStorageConfig.MODE_BEST_EFFORT,
163163
"PREFLIGHT": DownsampledStorageConfig.MODE_PREFLIGHT,
164164
"NORMAL": DownsampledStorageConfig.MODE_NORMAL,
165+
"HIGHEST_ACCURACY": DownsampledStorageConfig.MODE_HIGHEST_ACCURACY,
165166
}

src/sentry/search/eap/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def transform_column_to_expression(column: Column) -> Expression:
102102

103103
def validate_sampling(sampling_mode: SAMPLING_MODES | None) -> DownsampledStorageConfig:
104104
if sampling_mode is None:
105-
return DownsampledStorageConfig(mode=DownsampledStorageConfig.MODE_UNSPECIFIED)
105+
return DownsampledStorageConfig(mode=DownsampledStorageConfig.MODE_HIGHEST_ACCURACY)
106106
if sampling_mode not in SAMPLING_MODE_MAP:
107107
raise InvalidSearchQuery(f"sampling mode: {sampling_mode} is not supported")
108108
else:

src/sentry/search/events/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class EventsResponse(TypedDict):
8181
meta: EventsMeta
8282

8383

84-
SAMPLING_MODES = Literal["BEST_EFFORT", "PREFLIGHT", "NORMAL"]
84+
SAMPLING_MODES = Literal["BEST_EFFORT", "PREFLIGHT", "NORMAL", "HIGHEST_ACCURACY"]
8585

8686

8787
@dataclass

tests/snuba/api/endpoints/test_organization_events_stats_span_indexed.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,3 +2017,32 @@ def test_downsampling_can_go_to_higher_accuracy_tier(self):
20172017
)
20182018

20192019
assert response.data["meta"]["dataScanned"] == "partial"
2020+
2021+
def test_request_without_sampling_mode_defaults_to_highest_accuracy(self):
2022+
response = self._do_request(
2023+
data={
2024+
"start": self.day_ago,
2025+
"end": self.day_ago + timedelta(minutes=3),
2026+
"interval": "1m",
2027+
"yAxis": "count()",
2028+
"project": self.project.id,
2029+
"dataset": self.dataset,
2030+
},
2031+
)
2032+
2033+
assert response.data["meta"]["dataScanned"] == "full"
2034+
2035+
def test_request_to_highest_accuracy_mode(self):
2036+
response = self._do_request(
2037+
data={
2038+
"start": self.day_ago,
2039+
"end": self.day_ago + timedelta(minutes=3),
2040+
"interval": "1m",
2041+
"yAxis": "count()",
2042+
"project": self.project.id,
2043+
"dataset": self.dataset,
2044+
"sampling": "HIGHEST_ACCURACY",
2045+
},
2046+
)
2047+
2048+
assert response.data["meta"]["dataScanned"] == "full"

0 commit comments

Comments
 (0)