|
@@ -19,7 +19,6 @@ from snuba_sdk import (
|
|
from sentry.dynamic_sampling.tasks.common import get_adjusted_base_rate_from_cache_or_compute
|
|
from sentry.dynamic_sampling.tasks.common import get_adjusted_base_rate_from_cache_or_compute
|
|
from sentry.dynamic_sampling.tasks.constants import (
|
|
from sentry.dynamic_sampling.tasks.constants import (
|
|
MAX_REBALANCE_FACTOR,
|
|
MAX_REBALANCE_FACTOR,
|
|
- MAX_SECONDS,
|
|
|
|
MIN_REBALANCE_FACTOR,
|
|
MIN_REBALANCE_FACTOR,
|
|
RECALIBRATE_ORGS_QUERY_INTERVAL,
|
|
RECALIBRATE_ORGS_QUERY_INTERVAL,
|
|
)
|
|
)
|
|
@@ -31,6 +30,7 @@ from sentry.dynamic_sampling.tasks.helpers.recalibrate_orgs import (
|
|
)
|
|
)
|
|
from sentry.dynamic_sampling.tasks.logging import (
|
|
from sentry.dynamic_sampling.tasks.logging import (
|
|
log_action_if,
|
|
log_action_if,
|
|
|
|
+ log_query_timeout,
|
|
log_recalibrate_org_error,
|
|
log_recalibrate_org_error,
|
|
log_recalibrate_org_state,
|
|
log_recalibrate_org_state,
|
|
log_sample_rate_source,
|
|
log_sample_rate_source,
|
|
@@ -43,6 +43,10 @@ from sentry.snuba.referrer import Referrer
|
|
from sentry.tasks.base import instrumented_task
|
|
from sentry.tasks.base import instrumented_task
|
|
from sentry.utils.snuba import raw_snql_query
|
|
from sentry.utils.snuba import raw_snql_query
|
|
|
|
|
|
|
|
+# Since we are using a granularity of 60 (minute granularity), we want to have a higher time upper limit for executing
|
|
|
|
+# multiple queries on Snuba.
|
|
|
|
+RECALIBRATE_ORGS_MAX_SECONDS = 600
|
|
|
|
+
|
|
|
|
|
|
class RecalibrationError(Exception):
|
|
class RecalibrationError(Exception):
|
|
def __init__(self, org_id, message):
|
|
def __init__(self, org_id, message):
|
|
@@ -166,7 +170,7 @@ def get_active_orgs(
|
|
metric_id = indexer.resolve_shared_org(str(TransactionMRI.COUNT_PER_ROOT_PROJECT.value))
|
|
metric_id = indexer.resolve_shared_org(str(TransactionMRI.COUNT_PER_ROOT_PROJECT.value))
|
|
offset = 0
|
|
offset = 0
|
|
|
|
|
|
- while (time.time() - start_time) < MAX_SECONDS:
|
|
|
|
|
|
+ while (time.time() - start_time) < RECALIBRATE_ORGS_MAX_SECONDS:
|
|
query = (
|
|
query = (
|
|
Query(
|
|
Query(
|
|
match=Entity(EntityKey.GenericOrgMetricsCounters.value),
|
|
match=Entity(EntityKey.GenericOrgMetricsCounters.value),
|
|
@@ -212,6 +216,10 @@ def get_active_orgs(
|
|
|
|
|
|
if not more_results:
|
|
if not more_results:
|
|
return
|
|
return
|
|
|
|
+ else:
|
|
|
|
+ log_query_timeout(
|
|
|
|
+ query="get_active_orgs", offset=offset, timeout_seconds=RECALIBRATE_ORGS_MAX_SECONDS
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
def fetch_org_volumes(
|
|
def fetch_org_volumes(
|