Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/sentry/utils/rollout.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import random
from collections.abc import Callable
from typing import Any, Literal, TypeVar
from typing import Any, Literal, TypeVar, cast

from sentry import options
from sentry.options import register
Expand Down Expand Up @@ -154,9 +154,10 @@ def _callsite_mismatch_log_allowlist_option(cls) -> str:
def _callsite_use_experimental_data_allowlist_option(cls) -> str:
"""
This is the callsite-level use-experimental-path rollout option. If the option value
contains a callsite, then that callsite will use the experimental-path data. This should
generally only be used once you've determined that there is a high rate of partial- or
exact- match at the callsite. Defaults to an empty list.
contains a callsite, then that callsite will use the experimental-path data. Use ``*`` to
enable the experimental path for all callsites. This should generally only be used once
you've determined that there is a high rate of partial- or exact-match. Defaults to an
empty list.
"""
return f"dynamic.saferollouts.{cls.ROLLOUT_NAME}.use_experimental_data_callsite_allowlist"

Expand Down Expand Up @@ -331,15 +332,16 @@ def should_check_experiment(cls, callsite: str) -> bool:
def should_use_experimental_data(cls, callsite: str) -> bool:
"""
This function controls whether you use the result of your experimental data. Useful for
allowlisting known-safe callsites.
allowlisting known-safe callsites. The special callsite ``*`` allows all callsites.

Note: If you are transitioning from an existing, intended-to-be-equivalent dataset, you
should instead use `check_and_choose` (which has this check built in and has better
logging).
"""
use_experimental_data = callsite in options.get(
cls._callsite_use_experimental_data_allowlist_option()
allowlist = cast(
list[str], options.get(cls._callsite_use_experimental_data_allowlist_option())
)
use_experimental_data = "*" in allowlist or callsite in allowlist
tags: dict[str, str] = {
"rollout_name": cls.ROLLOUT_NAME,
"callsite": callsite,
Expand Down
8 changes: 8 additions & 0 deletions tests/sentry/utils/test_rollout.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ def test_experimental_data_use(self) -> None:
TestRolloutComparator.check_and_choose("ctl", "exp", "known_good_callsite") == "exp"
)

with override_options(
{
TEST_CALLSITE_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: ["*"],
}
):
assert TestRolloutComparator.check_and_choose("ctl", "exp", "test_3") == "exp"
assert TestRolloutComparator.check_and_choose("ctl", "exp", "other") == "exp"

def test_comparator_use(self) -> None:
exact_matcher = lambda control, exp: exp["dogs"] == control["dogs"]
close_matcher = lambda control, exp: exp["dogs"].issubset(control["dogs"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setUp(self) -> None:

def request_with_feature_flag(self, payload: dict) -> Response:
with self.options(
{EAP_OCCURRENCES_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: self.callsite_name}
{EAP_OCCURRENCES_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: [self.callsite_name]}
):
response = self.do_request({**payload, "dataset": "occurrences"})
assert response.status_code == 200, response.content
Expand Down Expand Up @@ -526,7 +526,7 @@ def request_with_feature_flag(self, payload: dict) -> Response:
"organizations:trace-item-details-array-fields": True,
}
with self.options(
{EAP_OCCURRENCES_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: self.callsite_name}
{EAP_OCCURRENCES_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: [self.callsite_name]}
):
response = self.do_request({**payload, "dataset": "occurrences"}, features=features)
assert response.status_code == 200, response.content
Expand Down Expand Up @@ -784,7 +784,7 @@ def test_array_fields_dropped_when_feature_flag_off(self) -> None:
expected_http_url = expected[0]["http_url"]

with self.options(
{EAP_OCCURRENCES_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: self.callsite_name}
{EAP_OCCURRENCES_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: [self.callsite_name]}
):
response = self.do_request(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _store_occurrences_and_request_timeseries(
]
self.store_eap_items(occurrences)
with self.options(
{EAP_OCCURRENCES_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: self.callsite_name}
{EAP_OCCURRENCES_USE_EXPERIMENTAL_DATA_ALLOWLIST_OPTION: [self.callsite_name]}
):
return self._do_request(
data={
Expand Down
Loading