|
@@ -124,7 +124,7 @@ class TestBoostLowVolumeProjectsTasks(TasksTestCase):
|
|
|
def forecasted_volume_side_effect(*args, **kwargs):
|
|
|
return kwargs["volume"]
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_boost_low_volume_projects_simple(
|
|
|
self,
|
|
|
get_blended_sample_rate,
|
|
@@ -159,7 +159,7 @@ class TestBoostLowVolumeProjectsTasks(TasksTestCase):
|
|
|
}
|
|
|
assert generate_rules(proj_d)[0]["samplingValue"] == {"type": "sampleRate", "value": 1.0}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_boost_low_volume_projects_simple_with_empty_project(
|
|
|
self,
|
|
|
get_blended_sample_rate,
|
|
@@ -196,8 +196,8 @@ class TestBoostLowVolumeProjectsTasks(TasksTestCase):
|
|
|
assert generate_rules(proj_d)[0]["samplingValue"] == {"type": "sampleRate", "value": 1.0}
|
|
|
assert generate_rules(proj_e)[0]["samplingValue"] == {"type": "sampleRate", "value": 1.0}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_boost_low_volume_projects_simple_with_sliding_window_org_from_cache(
|
|
|
self,
|
|
@@ -238,8 +238,8 @@ class TestBoostLowVolumeProjectsTasks(TasksTestCase):
|
|
|
}
|
|
|
assert generate_rules(proj_d)[0]["samplingValue"] == {"type": "sampleRate", "value": 1.0}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_boost_low_volume_projects_simple_with_sliding_window_org_from_sync(
|
|
|
self,
|
|
@@ -284,8 +284,8 @@ class TestBoostLowVolumeProjectsTasks(TasksTestCase):
|
|
|
@patch(
|
|
|
"sentry.dynamic_sampling.tasks.boost_low_volume_projects.schedule_invalidate_project_config"
|
|
|
)
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_config_invalidation_when_sample_rates_change(
|
|
|
self,
|
|
@@ -316,8 +316,8 @@ class TestBoostLowVolumeProjectsTasks(TasksTestCase):
|
|
|
@patch(
|
|
|
"sentry.dynamic_sampling.tasks.boost_low_volume_projects.schedule_invalidate_project_config"
|
|
|
)
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_config_invalidation_when_sample_rates_do_not_change(
|
|
|
self,
|
|
@@ -454,7 +454,7 @@ class TestBoostLowVolumeTransactionsTasks(TasksTestCase):
|
|
|
)
|
|
|
)
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_boost_low_volume_transactions_with_blended_sample_rate(self, get_blended_sample_rate):
|
|
|
"""
|
|
|
Create orgs projects & transactions and then check that the task creates rebalancing data
|
|
@@ -479,7 +479,7 @@ class TestBoostLowVolumeTransactionsTasks(TasksTestCase):
|
|
|
) # check we have some rate calculated for each transaction
|
|
|
assert global_rate == BLENDED_RATE
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_boost_low_volume_transactions_with_sliding_window(self, get_blended_sample_rate):
|
|
|
"""
|
|
|
Create orgs projects & transactions and then check that the task creates rebalancing data
|
|
@@ -511,7 +511,7 @@ class TestBoostLowVolumeTransactionsTasks(TasksTestCase):
|
|
|
) # check we have some rate calculated for each transaction
|
|
|
assert global_rate == used_sample_rate
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_boost_low_volume_transactions_with_sliding_window_org(self, get_blended_sample_rate):
|
|
|
"""
|
|
|
Create orgs projects & transactions and then check that the task creates rebalancing data
|
|
@@ -560,7 +560,7 @@ class TestBoostLowVolumeTransactionsTasks(TasksTestCase):
|
|
|
|
|
|
assert global_rate == used_sample_rate
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_boost_low_volume_transactions_partial(self, get_blended_sample_rate):
|
|
|
"""
|
|
|
Test the V2 algorithm is used, only specified projects are balanced and the
|
|
@@ -650,7 +650,7 @@ class TestRecalibrateOrgsTasks(TasksTestCase):
|
|
|
org_id=org.id,
|
|
|
)
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_rebalance_orgs(self, get_blended_sample_rate):
|
|
|
"""
|
|
|
Test that the org are going to be rebalanced at 20%
|
|
@@ -701,7 +701,7 @@ class TestRecalibrateOrgsTasks(TasksTestCase):
|
|
|
# half it again to 0.25
|
|
|
assert float(val) == 0.25
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_rebalance_rules(self, get_blended_sample_rate):
|
|
|
"""
|
|
|
Test that we pass rebalancing values all the way to the rules
|
|
@@ -789,8 +789,8 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
is not None
|
|
|
)
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_sliding_window_with_multiple_projects(
|
|
|
self,
|
|
@@ -845,8 +845,8 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
"value": 1.0,
|
|
|
}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_sliding_window_with_none_sampling_tier(
|
|
|
self,
|
|
@@ -879,7 +879,7 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
"value": 0.5,
|
|
|
}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_sliding_window_with_forecasting_error(
|
|
|
self, extrapolate_monthly_volume, get_blended_sample_rate
|
|
@@ -902,7 +902,7 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
"value": 0.9,
|
|
|
}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.compute_sliding_window_sample_rate")
|
|
|
def test_sliding_window_with_sample_rate_computation_error(
|
|
|
self, compute_sliding_window_sample_rate, get_blended_sample_rate
|
|
@@ -925,8 +925,8 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
"value": 0.9,
|
|
|
}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_sliding_window_with_project_without_metrics(
|
|
|
self,
|
|
@@ -958,8 +958,8 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
"value": 1.0,
|
|
|
}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_sliding_window_with_all_projects_without_metrics(
|
|
|
self,
|
|
@@ -989,7 +989,7 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
"value": 1.0,
|
|
|
}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_sliding_window_with_none_window_size(self, get_blended_sample_rate):
|
|
|
get_blended_sample_rate.return_value = 0.5
|
|
|
|
|
@@ -1010,8 +1010,8 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
}
|
|
|
|
|
|
@patch("sentry.dynamic_sampling.tasks.sliding_window.schedule_invalidate_project_config")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_config_invalidation_when_sample_rates_change(
|
|
|
self,
|
|
@@ -1043,8 +1043,8 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
assert schedule_invalidate_project_config.call_count == 2
|
|
|
|
|
|
@patch("sentry.dynamic_sampling.tasks.sliding_window.schedule_invalidate_project_config")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_config_invalidation_when_sample_rates_do_not_change(
|
|
|
self,
|
|
@@ -1076,8 +1076,8 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
schedule_invalidate_project_config.assert_not_called()
|
|
|
|
|
|
@patch("sentry.dynamic_sampling.tasks.sliding_window.schedule_invalidate_project_config")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_transaction_sampling_tier_for_volume")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_transaction_sampling_tier_for_volume")
|
|
|
@patch("sentry.dynamic_sampling.tasks.common.extrapolate_monthly_volume")
|
|
|
def test_cache_deletion_when_project_has_no_more_metrics(
|
|
|
self,
|
|
@@ -1127,7 +1127,7 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
"value": 1.0,
|
|
|
}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_sliding_window_with_new_project(self, get_blended_sample_rate):
|
|
|
get_blended_sample_rate.return_value = 0.5
|
|
|
|
|
@@ -1147,7 +1147,7 @@ class TestSlidingWindowTasks(TasksTestCase):
|
|
|
"value": 1.0,
|
|
|
}
|
|
|
|
|
|
- @patch("sentry.dynamic_sampling.rules.base.quotas.get_blended_sample_rate")
|
|
|
+ @patch("sentry.quotas.backend.get_blended_sample_rate")
|
|
|
def test_sliding_window_with_new_org(self, get_blended_sample_rate):
|
|
|
get_blended_sample_rate.return_value = 0.5
|
|
|
|