From 41808c642c282100e3d3e71d00a3031ca4bc637f Mon Sep 17 00:00:00 2001 From: Yiming Luo <10097700+lym953@users.noreply.github.com> Date: Mon, 13 Apr 2026 15:07:43 -0400 Subject: [PATCH 1/3] fix: [SVLS-8538] apply durable function tags via setTag on the active span Tags for aws_lambda.durable_function.* were set through options.tags in tracer.wrap(), but that path does not reliably reach the aws.lambda span. Apply them directly via span.setTag() in onEndingInvocation(), the same way http.status_code is applied. Co-Authored-By: Claude Sonnet 4.6 --- src/trace/listener.spec.ts | 24 ++++++++++++++++++++++++ src/trace/listener.ts | 15 ++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/trace/listener.spec.ts b/src/trace/listener.spec.ts index 6a9a9e20..f70865fa 100644 --- a/src/trace/listener.spec.ts +++ b/src/trace/listener.spec.ts @@ -544,4 +544,28 @@ describe("TraceListener", () => { ); }); }); + + it("sets durable function context tags directly on the aws.lambda span", async () => { + const mockSetTag = jest.fn(); + const mockSpan = { setTag: mockSetTag }; + const currentSpanSpy = jest.spyOn(TracerWrapper.prototype, "currentSpan", "get").mockReturnValue(mockSpan); + + try { + const listener = new TraceListener(defaultConfig); + const durableEvent = { + DurableExecutionArn: + "arn:aws:lambda:us-east-1:123456789012:function:my-func:1/durable-execution/my-execution/550e8400-e29b-41d4-a716-446655440004", + }; + await listener.onStartInvocation(durableEvent, context as any); + listener.onEndingInvocation(durableEvent, {}, false); + + expect(mockSetTag).toHaveBeenCalledWith("aws_lambda.durable_function.execution_name", "my-execution"); + expect(mockSetTag).toHaveBeenCalledWith( + "aws_lambda.durable_function.execution_id", + "550e8400-e29b-41d4-a716-446655440004", + ); + } finally { + currentSpanSpy.mockRestore(); + } + }); }); diff --git a/src/trace/listener.ts b/src/trace/listener.ts index d846d7d4..217ba7a8 100644 --- a/src/trace/listener.ts +++ b/src/trace/listener.ts @@ -226,6 +226,14 @@ export class TraceListener { } } } + if (this.durableFunctionContext) { + logDebug("Applying durable function context to the aws.lambda span"); + for (const [key, value] of Object.entries(this.durableFunctionContext)) { + if (value !== undefined) { + this.tracerWrapper.currentSpan.setTag(key, value); + } + } + } let rootSpan = this.inferredSpan; if (!rootSpan) { @@ -337,13 +345,6 @@ export class TraceListener { ...this.stepFunctionContext, }; } - if (this.durableFunctionContext) { - logDebug("Applying durable function context to the aws.lambda span"); - options.tags = { - ...options.tags, - ...this.durableFunctionContext, - }; - } if (this.lambdaSpanParentContext) { options.childOf = this.lambdaSpanParentContext; } From 7360ba3af79d3a65583384abd9440e9e1b562c82 Mon Sep 17 00:00:00 2001 From: Yiming Luo <10097700+lym953@users.noreply.github.com> Date: Mon, 13 Apr 2026 15:10:50 -0400 Subject: [PATCH 2/3] remove logDebug from durable function tag application Co-Authored-By: Claude Sonnet 4.6 --- src/trace/listener.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/trace/listener.ts b/src/trace/listener.ts index 217ba7a8..76951f4b 100644 --- a/src/trace/listener.ts +++ b/src/trace/listener.ts @@ -227,7 +227,6 @@ export class TraceListener { } } if (this.durableFunctionContext) { - logDebug("Applying durable function context to the aws.lambda span"); for (const [key, value] of Object.entries(this.durableFunctionContext)) { if (value !== undefined) { this.tracerWrapper.currentSpan.setTag(key, value); From 1fa15a6718ef7ac6f41ba6f39d8672ade5f053b5 Mon Sep 17 00:00:00 2001 From: Yiming Luo <10097700+lym953@users.noreply.github.com> Date: Mon, 13 Apr 2026 15:30:18 -0400 Subject: [PATCH 3/3] add back logDebug for durable function tag application Co-Authored-By: Claude Sonnet 4.6 --- src/trace/listener.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/trace/listener.ts b/src/trace/listener.ts index 76951f4b..217ba7a8 100644 --- a/src/trace/listener.ts +++ b/src/trace/listener.ts @@ -227,6 +227,7 @@ export class TraceListener { } } if (this.durableFunctionContext) { + logDebug("Applying durable function context to the aws.lambda span"); for (const [key, value] of Object.entries(this.durableFunctionContext)) { if (value !== undefined) { this.tracerWrapper.currentSpan.setTag(key, value);