From d0c6aefe8794fc479ad1c65236f501b4ff793750 Mon Sep 17 00:00:00 2001 From: Ted Kaemming <65315+tkaemming@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:42:41 -0700 Subject: [PATCH] Better name for the setting as this is sort of decoupled from overflow (but also not really) --- posthog/api/capture.py | 2 +- posthog/settings/ingestion.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/posthog/api/capture.py b/posthog/api/capture.py index 3d67911f4a8b4..6b921dd27ea48 100644 --- a/posthog/api/capture.py +++ b/posthog/api/capture.py @@ -624,7 +624,7 @@ def capture_internal( candidate_partition_key = f"{token}:{distinct_id}" if ( not historical - and settings.CAPTURE_OVERFLOW_ENABLED + and settings.CAPTURE_ALLOW_RANDOM_PARTITIONING and (distinct_id.lower() in LIKELY_ANONYMOUS_IDS or is_randomly_partitioned(candidate_partition_key)) ): kafka_partition_key = None diff --git a/posthog/settings/ingestion.py b/posthog/settings/ingestion.py index 3b4d039a25b20..efbe05371d5e3 100644 --- a/posthog/settings/ingestion.py +++ b/posthog/settings/ingestion.py @@ -11,10 +11,12 @@ # KEEP IN SYNC WITH plugin-server/src/config/config.ts BUFFER_CONVERSION_SECONDS = get_from_env("BUFFER_CONVERSION_SECONDS", default=60, type_cast=int) -# Whether or not overflow (random partitioning) should be enabled *at all*. -# Note that this setting takes precedence over other overflow-related settings -# below, if disabled. -CAPTURE_OVERFLOW_ENABLED = get_from_env("CAPTURE_OVERFLOW_ENABLED", True, type_cast=str_to_bool) +# Whether or not random partitioning (i.e. overflow routing) should be enabled +# at all. Enabling this setting this does not cause messages to be randomly +# partitioned, but only allows them to be be randomly partitioned if other +# criteria are met. Note that this setting takes precedence over other +# partition-related settings below, if disabled. +CAPTURE_ALLOW_RANDOM_PARTITIONING = get_from_env("CAPTURE_ALLOW_RANDOM_PARTITIONING", True, type_cast=str_to_bool) # A list of pairs (in the format 2:myLovelyId) that we should use # random partitioning for when producing events to the Kafka topic consumed by the plugin server.