From 29b1220a90ff7edc92d3aa9648e294bc4da0028f Mon Sep 17 00:00:00 2001 From: Dmitrii Date: Tue, 2 Jun 2026 17:46:11 +0300 Subject: [PATCH] refactor(core): Rename N8N_OTEL_TRACES_PUBLISHED_ONLY env var to N8N_OTEL_TRACES_PRODUCTION_ONLY (#31575) --- .../__tests__/otel-lifecycle-handler.test.ts | 20 +++++++++---------- .../otel-workflow-tracing.integration.test.ts | 2 +- .../modules/otel/otel-lifecycle-handler.ts | 10 +++++----- packages/cli/src/modules/otel/otel.config.ts | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/cli/src/modules/otel/__tests__/otel-lifecycle-handler.test.ts b/packages/cli/src/modules/otel/__tests__/otel-lifecycle-handler.test.ts index c04358b6df2..98f1df634e5 100644 --- a/packages/cli/src/modules/otel/__tests__/otel-lifecycle-handler.test.ts +++ b/packages/cli/src/modules/otel/__tests__/otel-lifecycle-handler.test.ts @@ -75,7 +75,7 @@ describe('OtelLifecycleHandler', () => { beforeEach(() => { jest.clearAllMocks(); - config = makeOtelConfig({ publishedOnly: false }); + config = makeOtelConfig({ productionExecutionsOnly: false }); handler = new OtelLifecycleHandler( tracer, traceContextService, @@ -321,7 +321,7 @@ describe('OtelLifecycleHandler', () => { beforeEach(() => { jest.clearAllMocks(); - config = makeOtelConfig({ publishedOnly: false }); + config = makeOtelConfig({ productionExecutionsOnly: false }); handler = new OtelLifecycleHandler( tracer, traceContextService, @@ -437,7 +437,7 @@ describe('OtelLifecycleHandler', () => { beforeEach(() => { jest.clearAllMocks(); - config = makeOtelConfig({ publishedOnly: false }); + config = makeOtelConfig({ productionExecutionsOnly: false }); handler = new OtelLifecycleHandler( tracer, traceContextService, @@ -542,7 +542,7 @@ describe('OtelLifecycleHandler', () => { beforeEach(() => { jest.clearAllMocks(); - config = makeOtelConfig({ publishedOnly: false, includeNodeSpans: true }); + config = makeOtelConfig({ productionExecutionsOnly: false, includeNodeSpans: true }); handler = new OtelLifecycleHandler( tracer, traceContextService, @@ -636,7 +636,7 @@ describe('OtelLifecycleHandler', () => { }); }); -describe('publishedOnly filter', () => { +describe('productionExecutionsOnly filter', () => { const tracer = mock(); const traceContextService = mock(); let config = makeOtelConfig(); @@ -705,7 +705,7 @@ describe('publishedOnly filter', () => { beforeEach(() => { jest.clearAllMocks(); - config = makeOtelConfig({ publishedOnly: true, includeNodeSpans: true }); + config = makeOtelConfig({ productionExecutionsOnly: true, includeNodeSpans: true }); ownershipService.getWorkflowProjectCached.mockResolvedValue({ id: 'proj-1' } as never); traceContextService.get.mockResolvedValue(undefined); handler = new OtelLifecycleHandler( @@ -717,7 +717,7 @@ describe('publishedOnly filter', () => { ); }); - it('should skip all tracing for an inactive workflow when publishedOnly is true', async () => { + it('should skip all tracing for an inactive workflow when productionExecutionsOnly is true', async () => { await handler.onWorkflowStart(makeWorkflowStartCtx(inactiveWorkflow)); handler.onWorkflowEnd(makeWorkflowEndCtx(inactiveWorkflow)); handler.onNodeStart(makeNodeStartCtx(inactiveWorkflow)); @@ -730,7 +730,7 @@ describe('publishedOnly filter', () => { expect(tracer.endNode).not.toHaveBeenCalled(); }); - it('should trace an active workflow when publishedOnly is true', async () => { + it('should trace an active workflow when productionExecutionsOnly is true', async () => { tracer.startWorkflow.mockReturnValue({ traceparent: '00-abc-def-01' }); await handler.onWorkflowStart(makeWorkflowStartCtx(activeWorkflow)); @@ -739,8 +739,8 @@ describe('publishedOnly filter', () => { expect(traceContextService.persist).toHaveBeenCalled(); }); - it('should trace an inactive workflow when publishedOnly is false', async () => { - config.publishedOnly = false; + it('should trace an inactive workflow when productionExecutionsOnly is false', async () => { + config.productionExecutionsOnly = false; tracer.startWorkflow.mockReturnValue({ traceparent: '00-abc-def-01' }); await handler.onWorkflowStart(makeWorkflowStartCtx(inactiveWorkflow)); diff --git a/packages/cli/src/modules/otel/__tests__/otel-workflow-tracing.integration.test.ts b/packages/cli/src/modules/otel/__tests__/otel-workflow-tracing.integration.test.ts index 278ad21ace2..7bcb8ff40f2 100644 --- a/packages/cli/src/modules/otel/__tests__/otel-workflow-tracing.integration.test.ts +++ b/packages/cli/src/modules/otel/__tests__/otel-workflow-tracing.integration.test.ts @@ -30,7 +30,7 @@ beforeAll(async () => { savedEnv = saveAndSetEnv({ N8N_OTEL_ENABLED: 'true', N8N_OTEL_TRACES_INCLUDE_NODE_SPANS: 'true', - N8N_OTEL_TRACES_PUBLISHED_ONLY: 'false', + N8N_OTEL_TRACES_PRODUCTION_ONLY: 'false', }); const env = await initOtelTestEnvironment(); otel = env.otel; diff --git a/packages/cli/src/modules/otel/otel-lifecycle-handler.ts b/packages/cli/src/modules/otel/otel-lifecycle-handler.ts index b44f3ad5bc1..91e3e0e0b94 100644 --- a/packages/cli/src/modules/otel/otel-lifecycle-handler.ts +++ b/packages/cli/src/modules/otel/otel-lifecycle-handler.ts @@ -51,7 +51,7 @@ export class OtelLifecycleHandler { @OnLifecycleEvent('workflowExecuteBefore') async onWorkflowStart(ctx: WorkflowExecuteBeforeContext): Promise { - if (this.config.publishedOnly && !this.isPublishedWorkflow(ctx.workflow)) return; + if (this.config.productionExecutionsOnly && !this.isPublishedWorkflow(ctx.workflow)) return; const parentExecutionId = ctx.executionData?.parentExecution?.executionId; const tracingContext = parentExecutionId @@ -96,7 +96,7 @@ export class OtelLifecycleHandler { @OnLifecycleEvent('workflowExecuteResume') async onWorkflowResume(ctx: WorkflowExecuteResumeContext): Promise { - if (this.config.publishedOnly && !this.isPublishedWorkflow(ctx.workflow)) return; + if (this.config.productionExecutionsOnly && !this.isPublishedWorkflow(ctx.workflow)) return; const previousWorkflowExecution = await this.traceContextService.get(ctx.executionId); @@ -132,7 +132,7 @@ export class OtelLifecycleHandler { @OnLifecycleEvent('workflowExecuteAfter') onWorkflowEnd(ctx: WorkflowExecuteAfterContext): void { - if (this.config.publishedOnly && !this.isPublishedWorkflow(ctx.workflow)) return; + if (this.config.productionExecutionsOnly && !this.isPublishedWorkflow(ctx.workflow)) return; this.tracer.endWorkflow({ executionId: ctx.executionId, @@ -146,7 +146,7 @@ export class OtelLifecycleHandler { @OnLifecycleEvent('nodeExecuteBefore') onNodeStart(ctx: NodeExecuteBeforeContext): void { - if (this.config.publishedOnly && !this.isPublishedWorkflow(ctx.workflow)) return; + if (this.config.productionExecutionsOnly && !this.isPublishedWorkflow(ctx.workflow)) return; if (!this.config.includeNodeSpans) return; const node = ctx.workflow.nodes.find((n) => n.name === ctx.nodeName); @@ -160,7 +160,7 @@ export class OtelLifecycleHandler { @OnLifecycleEvent('nodeExecuteAfter') onNodeEnd(ctx: NodeExecuteAfterContext): void { - if (this.config.publishedOnly && !this.isPublishedWorkflow(ctx.workflow)) return; + if (this.config.productionExecutionsOnly && !this.isPublishedWorkflow(ctx.workflow)) return; if (!this.config.includeNodeSpans) return; const node = ctx.workflow.nodes.find((n) => n.name === ctx.nodeName); diff --git a/packages/cli/src/modules/otel/otel.config.ts b/packages/cli/src/modules/otel/otel.config.ts index 8eee25865d3..504efd1b0ac 100644 --- a/packages/cli/src/modules/otel/otel.config.ts +++ b/packages/cli/src/modules/otel/otel.config.ts @@ -29,7 +29,7 @@ export class OtelConfig { @Env('N8N_OTEL_TRACES_INJECT_OUTBOUND') injectOutbound: boolean = true; - /** When true, only traces executions of published (active) workflows. */ - @Env('N8N_OTEL_TRACES_PUBLISHED_ONLY') - publishedOnly: boolean = true; + /** When true, only traces production executions of published (active) workflows, not manual/test runs. */ + @Env('N8N_OTEL_TRACES_PRODUCTION_ONLY') + productionExecutionsOnly: boolean = true; }