From e7ee9ab35720401ff5094dd2cc222b10c8d3e7cd Mon Sep 17 00:00:00 2001 From: Enoch Tang Date: Wed, 12 Oct 2022 15:17:05 -0400 Subject: [PATCH] Move topics list to settings --- snuba/settings/__init__.py | 40 ++++++++++++++++++++++++++++++++ snuba/settings/validation.py | 44 ++++-------------------------------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/snuba/settings/__init__.py b/snuba/settings/__init__.py index 1b6992b9399..a4834c4299a 100644 --- a/snuba/settings/__init__.py +++ b/snuba/settings/__init__.py @@ -82,6 +82,46 @@ }, ] +ALLOWED_TOPICS: Set[str] = { + "events", + "event-replacements", + "transactions", + "snuba-commit-log", + "snuba-transactions-commit-log", + "snuba-sessions-commit-log", + "snuba-metrics-commit-log", + "cdc", + "snuba-metrics", + "outcomes", + "ingest-sessions", + "snuba-queries", + "scheduled-subscriptions-events", + "scheduled-subscriptions-transactions", + "scheduled-subscriptions-sessions", + "scheduled-subscriptions-metrics", + "scheduled-subscriptions-generic-metrics-sets", + "scheduled-subscriptions-generic-metrics-distributions", + "events-subscription-results", + "transactions-subscription-results", + "sessions-subscription-results", + "metrics-subscription-results", + "generic-metrics-sets-subscription-results", + "generic-metrics-distributions-subscription-results", + "snuba-dead-letter-inserts", + "processed-profiles", + "snuba-attribution", + "profiles-call-tree", + "ingest-replay-events", + "snuba-replay-events", + "snuba-dead-letter-replays", + "snuba-generic-metrics", + "snuba-generic-metrics-sets-commit-log", + "snuba-generic-metrics-distributions-commit-log", + "snuba-dead-letter-generic-metrics", + "snuba-dead-letter-sessions", + "snuba-dead-letter-metrics", +} + # Dogstatsd Options DOGSTATSD_HOST: str | None = None DOGSTATSD_PORT: int | None = None diff --git a/snuba/settings/validation.py b/snuba/settings/validation.py index 08ade3b3a42..fa212eff638 100644 --- a/snuba/settings/validation.py +++ b/snuba/settings/validation.py @@ -1,4 +1,4 @@ -from typing import Any, Mapping, MutableMapping +from typing import Any, Mapping, MutableMapping, Optional, Set from snuba.datasets.partitioning import SENTRY_LOGICAL_PARTITIONS @@ -28,45 +28,9 @@ def validate_settings(locals: Mapping[str, Any]) -> None: "DEFAULT_STORAGE_BROKERS is deprecated. Use KAFKA_BROKER_CONFIG instead." ) - topic_names = { - "events", - "event-replacements", - "transactions", - "snuba-commit-log", - "snuba-transactions-commit-log", - "snuba-sessions-commit-log", - "snuba-metrics-commit-log", - "cdc", - "snuba-metrics", - "outcomes", - "ingest-sessions", - "snuba-queries", - "scheduled-subscriptions-events", - "scheduled-subscriptions-transactions", - "scheduled-subscriptions-sessions", - "scheduled-subscriptions-metrics", - "scheduled-subscriptions-generic-metrics-sets", - "scheduled-subscriptions-generic-metrics-distributions", - "events-subscription-results", - "transactions-subscription-results", - "sessions-subscription-results", - "metrics-subscription-results", - "generic-metrics-sets-subscription-results", - "generic-metrics-distributions-subscription-results", - "snuba-dead-letter-inserts", - "processed-profiles", - "snuba-attribution", - "profiles-call-tree", - "ingest-replay-events", - "snuba-replay-events", - "snuba-dead-letter-replays", - "snuba-generic-metrics", - "snuba-generic-metrics-sets-commit-log", - "snuba-generic-metrics-distributions-commit-log", - "snuba-dead-letter-generic-metrics", - "snuba-dead-letter-sessions", - "snuba-dead-letter-metrics", - } + topic_names: Optional[Set[str]] = locals.get("ALLOWED_TOPICS") + if not topic_names: + topic_names = set() for key in locals["KAFKA_TOPIC_MAP"].keys(): if key not in topic_names: