mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-03 18:27:09 +02:00
refactor(core): Rename N8N_OTEL_TRACES_PUBLISHED_ONLY env var to N8N_OTEL_TRACES_PRODUCTION_ONLY (#31575)
This commit is contained in:
parent
8de9958c5f
commit
29b1220a90
|
|
@ -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<ExecutionLevelTracer>();
|
||||
const traceContextService = mock<TraceContextService>();
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export class OtelLifecycleHandler {
|
|||
|
||||
@OnLifecycleEvent('workflowExecuteBefore')
|
||||
async onWorkflowStart(ctx: WorkflowExecuteBeforeContext): Promise<void> {
|
||||
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<void> {
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user