Skip to content

: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.

fix(error-tracking): route cymbal rate-limiter app_metrics to warpstream-ingestion (#66514)

Aleksander Błaszkiewicz239799a214bd
diff --git a/rust/cymbal/src/modes/processing/app_context.rs b/rust/cymbal/src/modes/processing/app_context.rs
index c34c635985ed..baa0c43c2aa5 100644
--- a/rust/cymbal/src/modes/processing/app_context.rs
+++ b/rust/cymbal/src/modes/processing/app_context.rs
@@ -32,6 +32,10 @@ pub struct AppContext {
// Dedicated producer for `cdp_internal_events`. Points at warpstream-cyclotron when
// `CYMBAL_CYCLOTRON_KAFKA_HOSTS` is set; otherwise falls back to `immediate_producer`.
pub cyclotron_producer: FutureProducer<KafkaContext>,
+ // Dedicated producer for `clickhouse_app_metrics2`. Points at warpstream-ingestion when
+ // `CYMBAL_APP_METRICS_KAFKA_HOSTS` is set; otherwise falls back to `immediate_producer`.
+ // The primary producer's cluster (warpstream-shared) does not carry that topic.
+ pub app_metrics_producer: FutureProducer<KafkaContext>,
pub posthog_pool: PgPool,
pub catalog: Arc<Catalog>,
pub symbol_resolver: Arc<dyn SymbolResolver>,
@@ -134,6 +138,24 @@ impl AppContext {
_ => immediate_producer.clone(),
};
+ // Build the app-metrics producer if a separate broker list is configured; otherwise
+ // reuse the primary producer (so local dev, where one cluster carries every topic,
+ // works without extra config).
+ let app_metrics_producer = match config.app_metrics_kafka_hosts.as_deref() {
+ Some(hosts) if !hosts.is_empty() => {
+ let mut app_metrics_config = config.kafka.clone();
+ app_metrics_config.kafka_hosts = hosts.to_string();
+ if let Some(tls) = config.app_metrics_kafka_tls {
+ app_metrics_config.kafka_tls = tls;
+ }
+ let kafka_app_metrics_liveness = health_registry
+ .register("app_metrics_kafka".to_string(), Duration::from_secs(30))
+ .await;
+ create_kafka_producer(&app_metrics_config, kafka_app_metrics_liveness).await?
+ }
+ _ => immediate_producer.clone(),
+ };
+
s3_client
.ping_bucket(&config.resolver.object_storage_bucket)
.await?;
@@ -180,6 +202,7 @@ impl AppContext {
health_registry,
immediate_producer,
cyclotron_producer,
+ app_metrics_producer,
posthog_pool,
catalog,
config: config.clone(),
diff --git a/rust/cymbal/src/modes/processing/config.rs b/rust/cymbal/src/modes/processing/config.rs
index 0c2125e75c78..9b7461b5d161 100644
--- a/rust/cymbal/src/modes/processing/config.rs
+++ b/rust/cymbal/src/modes/processing/config.rs
@@ -46,6 +46,18 @@ pub struct ProcessingConfig {
#[envconfig(from = "CYMBAL_CYCLOTRON_KAFKA_TLS")]
pub cyclotron_kafka_tls: Option<bool>,
+ // Optional override for the brokers used to produce `clickhouse_app_metrics2`. When set,
+ // cymbal opens a dedicated producer pointed at this host list (the warpstream-ingestion VC,
+ // where ClickHouse consumes app_metrics2). When unset, app metrics go through the primary
+ // `kafka` producer — which only carries that topic where the cluster has it (e.g. local dev).
+ #[envconfig(from = "CYMBAL_APP_METRICS_KAFKA_HOSTS")]
+ pub app_metrics_kafka_hosts: Option<String>,
+
+ // Optional TLS override for the app-metrics producer. When unset, it inherits `KAFKA_TLS`
+ // from the primary kafka config.
+ #[envconfig(from = "CYMBAL_APP_METRICS_KAFKA_TLS")]
+ pub app_metrics_kafka_tls: Option<bool>,
+
#[envconfig(default = "cdp_internal_events")]
pub internal_events_topic: String,
diff --git a/rust/cymbal/src/modes/processing/stages/rate_limiting/mod.rs b/rust/cymbal/src/modes/processing/stages/rate_limiting/mod.rs
index 9bf19897b133..ff403ed3ce8f 100644
--- a/rust/cymbal/src/modes/processing/stages/rate_limiting/mod.rs
+++ b/rust/cymbal/src/modes/processing/stages/rate_limiting/mod.rs
@@ -270,7 +270,7 @@ impl RateLimitingStage {
}
let results = send_iter_to_kafka(
- &self.ctx.immediate_producer,
+ &self.ctx.app_metrics_producer,
APP_METRICS2_TOPIC,
app_metrics,
)