: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): accept hog function logs as an internal source (#128096)
Jon McCallum482288ee2f86
diff --git a/nodejs/src/cdp/services/monitoring/hog-function-monitoring.service.test.ts b/nodejs/src/cdp/services/monitoring/hog-function-monitoring.service.test.tsindex 44c5073a3609..c6299fef4cec 100644--- a/nodejs/src/cdp/services/monitoring/hog-function-monitoring.service.test.ts+++ b/nodejs/src/cdp/services/monitoring/hog-function-monitoring.service.test.ts@@ -149,11 +149,7 @@ describe('HogFunctionMonitoringService', () => {it('sends accepted logs to the logs product with the log entry timestamps, and drains them on stop', async () => {const fetchMock = jest.mocked(internalFetch).mockResolvedValue({ status: 200, dump: jest.fn() } as any)- service = new HogFunctionMonitoringService(- outputs,- internalLogsProducer(),- new Set(['hog_flow', 'hog_function'])- )+ service = new HogFunctionMonitoringService(outputs, internalLogsProducer(), new Set(['hog_flow']))service.queueLogs([log(2), log(2), log(3)], 'hog_flow')service.queueLogs([log(2)], 'hog_function')diff --git a/nodejs/src/logs/internal-logs-producer.test.ts b/nodejs/src/logs/internal-logs-producer.test.tsindex e53aeef00431..b9e97b30c25f 100644--- a/nodejs/src/logs/internal-logs-producer.test.ts+++ b/nodejs/src/logs/internal-logs-producer.test.ts@@ -73,8 +73,11 @@ describe('InternalLogsProducer', () => {jest.useRealTimers()})- it('sends a batch the logs consumer verifies as internal', async () => {- await send(new InternalLogsProducer(config(), teamManager), [entry()])+ it.each([+ { source: 'hog_flow', serviceName: 'posthog-internal-workflows' },+ { source: 'hog_function', serviceName: 'posthog-internal-hog-functions' },+ ])('sends a $source batch the logs consumer verifies as internal', async ({ source, serviceName }) => {+ await send(new InternalLogsProducer(config(), teamManager), [entry()], source)expect(fetchMock).toHaveBeenCalledTimes(1)const [url, options] = fetchMock.mock.calls[0]@@ -83,15 +86,15 @@ describe('InternalLogsProducer', () => {expect(headers.Authorization).toEqual('Bearer phc_team_2')const verifier = new InternalLogsVerifier(KEY, '2')expect(verifier.verify(headers['x-posthog-internal'], 2, SIGNED_AT.toISOString())).toEqual({- source: 'hog_flow',+ source,billed: false,teamRules: false,- serviceName: 'posthog-internal-workflows',+ serviceName,})const body = parseJSON(options!.body as string) as anyexpect(body.resourceLogs[0].resource.attributes).toEqual([- { key: 'service.name', value: { stringValue: 'posthog-internal-workflows' } },+ { key: 'service.name', value: { stringValue: serviceName } },])expect(body.resourceLogs[0].scopeLogs[0].logRecords).toEqual([{@@ -131,7 +134,7 @@ describe('InternalLogsProducer', () => {it.each([{ name: 'a team not on the allowlist', entries: [entry({ team_id: 3 })] },- { name: 'a source with no policy', source: 'hog_function', entries: [entry()] },+ { name: 'a source with no policy', source: 'batch_exports', entries: [entry()] },{ name: 'no endpoint', overrides: { LOGS_INTERNAL_PRODUCER_URL: '' }, entries: [entry()] },{ name: 'no signing key', overrides: { LOGS_INTERNAL_INGESTION_SIGNING_KEYS: ' ' }, entries: [entry()] },{ name: 'an empty allowlist', overrides: { LOGS_INTERNAL_PRODUCER_TEAMS: '' }, entries: [entry()] },diff --git a/nodejs/src/logs/internal-logs.ts b/nodejs/src/logs/internal-logs.tsindex f692fdaacae6..e9ecebc4737a 100644--- a/nodejs/src/logs/internal-logs.ts+++ b/nodejs/src/logs/internal-logs.ts@@ -38,8 +38,7 @@ export type InternalLogs = InternalSourcePolicy & { source: string }// a free source. Moving a source to billing changes its entry here, not the producer or the header.export const INTERNAL_SOURCE_POLICIES: Readonly<Record<string, InternalSourcePolicy>> = {hog_flow: { billed: false, teamRules: false, serviceName: 'posthog-internal-workflows' },- // Each log_entries source moves unbilled, one at a time. Add a source when its producer starts signing.- // hog_function: { billed: false, teamRules: false, serviceName: '...' },+ hog_function: { billed: false, teamRules: false, serviceName: 'posthog-internal-hog-functions' },}type NotInternalReason =