: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(logs): add source topic and partition headers to clickhouse_logs messages (#107783)
Frank Hamand0fe1702167b9
diff --git a/nodejs/src/logs/__snapshots__/logs-ingestion-consumer.test.ts.snap b/nodejs/src/logs/__snapshots__/logs-ingestion-consumer.test.ts.snapindex 36ed54ed5ec4..56db6c9ada6e 100644--- a/nodejs/src/logs/__snapshots__/logs-ingestion-consumer.test.ts.snap+++ b/nodejs/src/logs/__snapshots__/logs-ingestion-consumer.test.ts.snap@@ -5,6 +5,8 @@ exports[`LogsIngestionConsumer general should process a valid log message 1`] ={"json-parse": "false","retention-days": "14",+ "source_partition": "1",+ "source_topic": "test","team_id": "TEAM_ID","token": "<REPLACED-UUID-0>",},@@ -16,18 +18,24 @@ exports[`LogsIngestionConsumer general should process multiple log messages 1`]{"json-parse": "false","retention-days": "14",+ "source_partition": "1",+ "source_topic": "test","team_id": "TEAM_ID","token": "<REPLACED-UUID-1>",},{"json-parse": "false","retention-days": "14",+ "source_partition": "1",+ "source_topic": "test","team_id": "TEAM_ID","token": "<REPLACED-UUID-1>",},{"json-parse": "false","retention-days": "14",+ "source_partition": "1",+ "source_topic": "test","team_id": "TEAM_ID","token": "<REPLACED-UUID-1>",},@@ -39,6 +47,8 @@ exports[`LogsIngestionConsumer message parsing and validation should overwrite e{"json-parse": "false","retention-days": "14",+ "source_partition": "1",+ "source_topic": "test","team_id": "TEAM_ID","token": "<REPLACED-UUID-3>",},@@ -51,6 +61,8 @@ exports[`LogsIngestionConsumer message parsing and validation should preserve ka"json-parse": "false","myHeader": "hello","retention-days": "14",+ "source_partition": "1",+ "source_topic": "test","team_id": "TEAM_ID","token": "<REPLACED-UUID-2>",},diff --git a/nodejs/src/logs/logs-ingestion-consumer.test.ts b/nodejs/src/logs/logs-ingestion-consumer.test.tsindex d9baf9dda198..65b4c846a411 100644--- a/nodejs/src/logs/logs-ingestion-consumer.test.ts+++ b/nodejs/src/logs/logs-ingestion-consumer.test.ts@@ -500,6 +500,8 @@ describe('LogsIngestionConsumer', () => {team_id: team.id.toString(),'json-parse': 'false','retention-days': DEFAULT_LOGS_RETENTION_DAYS.toString(),+ source_topic: messages[0].topic,+ source_partition: messages[0].partition.toString(),})})@@ -522,6 +524,8 @@ describe('LogsIngestionConsumer', () => {team_id: team.id.toString(),'json-parse': 'false','retention-days': DEFAULT_LOGS_RETENTION_DAYS.toString(),+ source_topic: messages[0].topic,+ source_partition: messages[0].partition.toString(),})})@@ -555,6 +559,8 @@ describe('LogsIngestionConsumer', () => {team_id: team.id.toString(),'json-parse': 'false','retention-days': '30',+ source_topic: messages[0].topic,+ source_partition: messages[0].partition.toString(),})})})diff --git a/nodejs/src/logs/logs-ingestion-consumer.ts b/nodejs/src/logs/logs-ingestion-consumer.tsindex 0ef1438a9dac..5cfd1845be1c 100644--- a/nodejs/src/logs/logs-ingestion-consumer.ts+++ b/nodejs/src/logs/logs-ingestion-consumer.ts@@ -1086,6 +1086,10 @@ export class LogsIngestionConsumer {team_id: message.teamId.toString(),'json-parse': jsonParse.toString(),'retention-days': retentionDays.toString(),+ // The ingestion lag checkpoint needs the source partition, because+ // both topics use random partitioning.+ source_topic: message.message.topic,+ source_partition: message.message.partition.toString(),...(bytesUncompressedHeaderOverride !== undefined? { bytes_uncompressed: bytesUncompressedHeaderOverride.toString() }: {}),