Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prepare to split save_event_transaction queue into 3 #78868

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 13 additions & 4 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from sentry.conf.types.role_dict import RoleDict
from sentry.conf.types.sdk_config import ServerSdkConfig
from sentry.utils import json # NOQA (used in getsentry config)
from sentry.utils.celery import crontab_with_minute_jitter
from sentry.utils.celery import crontab_with_minute_jitter, make_split_task_queues
from sentry.utils.types import Type, type_from_value


Expand Down Expand Up @@ -835,7 +835,16 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:
# Each route has a task name as key and a tuple containing a list of queues
# and a default one as destination. The default one is used when the
# rollout option is not active.
CELERY_SPLIT_QUEUE_TASK_ROUTES: Mapping[str, SplitQueueTaskRoute] = {}
CELERY_SPLIT_QUEUE_TASK_ROUTES: Mapping[str, SplitQueueTaskRoute] = {
"events.save_event_transaction": {
"default_queue": "events.save_event_transaction",
"queues_config": {
"total": 3,
"in_use": 3,
},
}
}
SPLIT_TASK_QUEUES = make_split_task_queues(CELERY_SPLIT_QUEUE_TASK_ROUTES)

# Mapping from queue name to split queues to be used by SplitQueueRouter.
# This is meant to be used in those case where we have to specify the
Expand Down Expand Up @@ -1266,12 +1275,12 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:
elif SILO_MODE == "REGION":
CELERYBEAT_SCHEDULE_FILENAME = os.path.join(tempfile.gettempdir(), "sentry-celerybeat-region")
CELERYBEAT_SCHEDULE = CELERYBEAT_SCHEDULE_REGION
CELERY_QUEUES = CELERY_QUEUES_REGION
CELERY_QUEUES = CELERY_QUEUES_REGION + SPLIT_TASK_QUEUES

else:
CELERYBEAT_SCHEDULE = {**CELERYBEAT_SCHEDULE_CONTROL, **CELERYBEAT_SCHEDULE_REGION}
CELERYBEAT_SCHEDULE_FILENAME = os.path.join(tempfile.gettempdir(), "sentry-celerybeat")
CELERY_QUEUES = CELERY_QUEUES_REGION + CELERY_QUEUES_CONTROL
CELERY_QUEUES = CELERY_QUEUES_REGION + CELERY_QUEUES_CONTROL + SPLIT_TASK_QUEUES

for queue in CELERY_QUEUES:
queue.durable = False
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/utils/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _build_queues(base: str, quantity: int) -> Sequence[Queue]:
return [Queue(name=name, routing_key=name) for name in build_queue_names(base, quantity)]


def make_split_task_queues(config: Mapping[str, SplitQueueTaskRoute]) -> Sequence[Queue]:
def make_split_task_queues(config: Mapping[str, SplitQueueTaskRoute]) -> list[Queue]:
"""
Generates the split queues definitions from the mapping between
a task name and a config expressed as `SplitQueueTaskRoute`.
Expand Down
Loading