:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(ingestion): make error-tracking overflow partition locality configurable (#58096)
Paweł Ledwoń01fcb752d91d
diff --git a/nodejs/src/ingestion/error-tracking/config.ts b/nodejs/src/ingestion/error-tracking/config.tsindex ca69a8984cfb..78b97347a45b 100644--- a/nodejs/src/ingestion/error-tracking/config.ts+++ b/nodejs/src/ingestion/error-tracking/config.ts@@ -30,6 +30,16 @@ export type ErrorTrackingConsumerConfig = {ERROR_TRACKING_STATEFUL_OVERFLOW_REDIS_TTL_SECONDS: number/** TTL in seconds for local cache entries */ERROR_TRACKING_STATEFUL_OVERFLOW_LOCAL_CACHE_TTL_SECONDS: number+ /**+ * When true (default, matching the previous hardcoded behavior), redirects+ * to the overflow lane keep the event's original partition key. When+ * false, the overflow producer emits with a null key and Kafka spreads+ * events across overflow-topic partitions. Cymbal cache locality is+ * enforced one layer down — by team_id consistent hashing inside+ * `CymbalClient` — so the partition key on the overflow lane doesn't+ * affect symbolication cache hits.+ */+ ERROR_TRACKING_OVERFLOW_PRESERVE_PARTITION_LOCALITY: boolean/** Max HTTP body size in bytes per Cymbal API request. Used to proactively* split large batches before they hit Cymbal's body limit. */@@ -68,6 +78,7 @@ export function getDefaultErrorTrackingConsumerConfig(): ErrorTrackingConsumerCoERROR_TRACKING_STATEFUL_OVERFLOW_ENABLED: false,ERROR_TRACKING_STATEFUL_OVERFLOW_REDIS_TTL_SECONDS: 300, // 5 minutesERROR_TRACKING_STATEFUL_OVERFLOW_LOCAL_CACHE_TTL_SECONDS: 60, // 1 minute+ ERROR_TRACKING_OVERFLOW_PRESERVE_PARTITION_LOCALITY: true,ERROR_TRACKING_CYMBAL_MAX_BODY_BYTES: 1_800_000,ERROR_TRACKING_RATE_LIMITER_ENABLED: false,ERROR_TRACKING_RATE_LIMITER_REPORTING_MODE: true,diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.test.ts b/nodejs/src/ingestion/error-tracking/error-tracking-consumer.test.tsindex 6ce4ee850617..201037ac7a5e 100644--- a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.test.ts+++ b/nodejs/src/ingestion/error-tracking/error-tracking-consumer.test.ts@@ -156,6 +156,7 @@ describe('ErrorTrackingConsumer', () => {statefulOverflowEnabled: hub.ERROR_TRACKING_STATEFUL_OVERFLOW_ENABLED,statefulOverflowRedisTTLSeconds: hub.ERROR_TRACKING_STATEFUL_OVERFLOW_REDIS_TTL_SECONDS,statefulOverflowLocalCacheTTLSeconds: hub.ERROR_TRACKING_STATEFUL_OVERFLOW_LOCAL_CACHE_TTL_SECONDS,+ preservePartitionLocality: hub.ERROR_TRACKING_OVERFLOW_PRESERVE_PARTITION_LOCALITY,pipeline: hub.INGESTION_PIPELINE ?? 'errortracking',rateLimiterEnabled: hub.ERROR_TRACKING_RATE_LIMITER_ENABLED,rateLimiterReportingMode: hub.ERROR_TRACKING_RATE_LIMITER_REPORTING_MODE,diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts b/nodejs/src/ingestion/error-tracking/error-tracking-consumer.tsindex e4bd0d3aba9b..cc329ea6f418 100644--- a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts+++ b/nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts@@ -53,6 +53,12 @@ export interface ErrorTrackingConsumerOptions {statefulOverflowEnabled: booleanstatefulOverflowRedisTTLSeconds: numberstatefulOverflowLocalCacheTTLSeconds: number+ /**+ * When true, overflow redirects keep the original partition key. When+ * false (default), the overflow producer emits with a null key. Applies+ * to both restriction-driven force-overflow and rate-limit-to-overflow.+ */+ preservePartitionLocality: booleanpipeline: stringrateLimiterEnabled: booleanrateLimiterReportingMode: boolean@@ -259,6 +265,7 @@ export class ErrorTrackingConsumer {groupTypeManager: this.deps.groupTypeManager,eventIngestionRestrictionManager: this.eventIngestionRestrictionManager,overflowEnabled: this.config.overflowEnabled,+ preservePartitionLocality: this.config.preservePartitionLocality,overflowRedirectService: this.overflowRedirectService,overflowLaneTTLRefreshService: this.overflowLaneTTLRefreshService,preCymbalRateLimiters: this.buildPreCymbalRateLimiterSpecs(),diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts b/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.tsindex b0d449cbf1de..aa7bec9c3fe4 100644--- a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts+++ b/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts@@ -308,6 +308,7 @@ describe('ErrorTrackingPipeline', () => {groupTypeManager: mockGroupTypeManager,eventIngestionRestrictionManager: mockEventIngestionRestrictionManager,overflowEnabled: false,+ preservePartitionLocality: false,topHog: mockTopHog,}})diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts b/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.tsindex 9b4ed2e2a896..145ffe2a2783 100644--- a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts+++ b/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts@@ -72,6 +72,16 @@ export interface ErrorTrackingPipelineConfig {groupTypeManager: GroupTypeManagereventIngestionRestrictionManager: EventIngestionRestrictionManageroverflowEnabled: boolean+ /**+ * When true, overflow redirects (both restriction-driven force-overflow+ * and rate-limit-to-overflow) keep the original partition key. When+ * false, redirects emit with a null key so Kafka spreads load across+ * overflow-topic partitions. Cymbal cache locality is enforced one layer+ * down (team_id consistent hashing inside `CymbalClient`), so the+ * partition key on the overflow lane doesn't affect symbolication cache+ * hits.+ */+ preservePartitionLocality: boolean/** Service for rate limiting and redirecting to overflow (main lane only). */overflowRedirectService?: OverflowRedirectService/** Service for refreshing TTLs on overflow lane events. */@@ -155,6 +165,7 @@ export function createErrorTrackingPipeline(groupTypeManager,eventIngestionRestrictionManager,overflowEnabled,+ preservePartitionLocality,overflowRedirectService,overflowLaneTTLRefreshService,preCymbalRateLimiters,@@ -180,7 +191,7 @@ export function createErrorTrackingPipeline(.pipe(createApplyEventRestrictionsStep(eventIngestionRestrictionManager, {overflowEnabled,- preservePartitionLocality: true,+ preservePartitionLocality,}))// Parse Kafka message body [REUSE]@@ -222,7 +233,7 @@ export function createErrorTrackingPipeline(// Rate limit high-volume token:distinct_id pairs to overflow.pipeBatch(createRateLimitToOverflowStep(- true, // preservePartitionLocality+ preservePartitionLocality,overflowRedirectService))diff --git a/nodejs/src/servers/error-tracking-server.ts b/nodejs/src/servers/error-tracking-server.tsindex 293953d69e61..de5a6c4210fa 100644--- a/nodejs/src/servers/error-tracking-server.ts+++ b/nodejs/src/servers/error-tracking-server.ts@@ -206,6 +206,7 @@ export class ErrorTrackingServer implements NodeServer {statefulOverflowRedisTTLSeconds: this.config.ERROR_TRACKING_STATEFUL_OVERFLOW_REDIS_TTL_SECONDS,statefulOverflowLocalCacheTTLSeconds:this.config.ERROR_TRACKING_STATEFUL_OVERFLOW_LOCAL_CACHE_TTL_SECONDS,+ preservePartitionLocality: this.config.ERROR_TRACKING_OVERFLOW_PRESERVE_PARTITION_LOCALITY,pipeline: this.config.INGESTION_PIPELINE ?? 'errortracking',rateLimiterEnabled: this.config.ERROR_TRACKING_RATE_LIMITER_ENABLED,rateLimiterReportingMode: this.config.ERROR_TRACKING_RATE_LIMITER_REPORTING_MODE,