Skip to content

Commit 45f99fa

Browse files
lym953claude
andauthored
[SVLS-8538] feat: rename durable function span tags to aws.durable.* (#778)
* refactor: rename durable function span tags to aws.durable.* Rename span tags on the aws.lambda span from aws_lambda.durable_function.* to aws.durable.* (execution_name, execution_id, first_invocation, execution_status). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * style: collapse single-line setTag assertion after rename Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b8f40e9 commit 45f99fa

4 files changed

Lines changed: 17 additions & 20 deletions

File tree

src/trace/durable-function-context.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ describe("durable-function-context", () => {
6060
const result = extractDurableFunctionContext(event);
6161

6262
expect(result).toEqual({
63-
"aws_lambda.durable_function.execution_name": "my-execution",
64-
"aws_lambda.durable_function.execution_id": "550e8400-e29b-41d4-a716-446655440004",
65-
"aws_lambda.durable_function.first_invocation": "false",
63+
"aws.durable.execution_name": "my-execution",
64+
"aws.durable.execution_id": "550e8400-e29b-41d4-a716-446655440004",
65+
"aws.durable.first_invocation": "false",
6666
});
6767
});
6868

@@ -76,7 +76,7 @@ describe("durable-function-context", () => {
7676
};
7777
const result = extractDurableFunctionContext(event);
7878

79-
expect(result?.["aws_lambda.durable_function.first_invocation"]).toBe("true");
79+
expect(result?.["aws.durable.first_invocation"]).toBe("true");
8080
});
8181

8282
it("sets first_invocation to false when Operations has more than one entry", () => {
@@ -89,7 +89,7 @@ describe("durable-function-context", () => {
8989
};
9090
const result = extractDurableFunctionContext(event);
9191

92-
expect(result?.["aws_lambda.durable_function.first_invocation"]).toBe("false");
92+
expect(result?.["aws.durable.first_invocation"]).toBe("false");
9393
});
9494

9595
it("omits first_invocation when InitialExecutionState is absent", () => {
@@ -100,7 +100,7 @@ describe("durable-function-context", () => {
100100
const result = extractDurableFunctionContext(event);
101101

102102
expect(result).toBeDefined();
103-
expect(result?.["aws_lambda.durable_function.first_invocation"]).toBeUndefined();
103+
expect(result?.["aws.durable.first_invocation"]).toBeUndefined();
104104
});
105105

106106
it("returns undefined for regular Lambda event without DurableExecutionArn", () => {

src/trace/durable-function-context.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { logDebug } from "../utils";
22

33
export interface DurableFunctionContext {
4-
"aws_lambda.durable_function.execution_name": string;
5-
"aws_lambda.durable_function.execution_id": string;
6-
"aws_lambda.durable_function.first_invocation"?: string;
4+
"aws.durable.execution_name": string;
5+
"aws.durable.execution_id": string;
6+
"aws.durable.first_invocation"?: string;
77
}
88

99
const VALID_DURABLE_EXECUTION_STATUSES = new Set(["SUCCEEDED", "FAILED", "PENDING"]);
@@ -22,14 +22,14 @@ export function extractDurableFunctionContext(event: any): DurableFunctionContex
2222
}
2323

2424
const context: DurableFunctionContext = {
25-
"aws_lambda.durable_function.execution_name": parsed.executionName,
26-
"aws_lambda.durable_function.execution_id": parsed.executionId,
25+
"aws.durable.execution_name": parsed.executionName,
26+
"aws.durable.execution_id": parsed.executionId,
2727
};
2828

2929
// Use the number of operations to determine if it's the first invocation.
3030
const operations = event?.InitialExecutionState?.Operations;
3131
if (Array.isArray(operations)) {
32-
context["aws_lambda.durable_function.first_invocation"] = String(operations.length === 1);
32+
context["aws.durable.first_invocation"] = String(operations.length === 1);
3333
}
3434

3535
return context;

src/trace/listener.spec.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,8 @@ describe("TraceListener", () => {
559559
await listener.onStartInvocation(durableEvent, context as any);
560560
listener.onEndingInvocation(durableEvent, {}, false);
561561

562-
expect(mockSetTag).toHaveBeenCalledWith("aws_lambda.durable_function.execution_name", "my-execution");
563-
expect(mockSetTag).toHaveBeenCalledWith(
564-
"aws_lambda.durable_function.execution_id",
565-
"550e8400-e29b-41d4-a716-446655440004",
566-
);
562+
expect(mockSetTag).toHaveBeenCalledWith("aws.durable.execution_name", "my-execution");
563+
expect(mockSetTag).toHaveBeenCalledWith("aws.durable.execution_id", "550e8400-e29b-41d4-a716-446655440004");
567564
} finally {
568565
currentSpanSpy.mockRestore();
569566
}
@@ -583,7 +580,7 @@ describe("TraceListener", () => {
583580
await listener.onStartInvocation(durableEvent, context as any);
584581
listener.onEndingInvocation(durableEvent, { Status: "SUCCEEDED" }, false);
585582

586-
expect(mockSetTag).toHaveBeenCalledWith("aws_lambda.durable_function.execution_status", "SUCCEEDED");
583+
expect(mockSetTag).toHaveBeenCalledWith("aws.durable.execution_status", "SUCCEEDED");
587584
} finally {
588585
currentSpanSpy.mockRestore();
589586
}
@@ -603,7 +600,7 @@ describe("TraceListener", () => {
603600
await listener.onStartInvocation(durableEvent, context as any);
604601
listener.onEndingInvocation(durableEvent, { Status: "UNKNOWN" }, false);
605602

606-
expect(mockSetTag).not.toHaveBeenCalledWith("aws_lambda.durable_function.execution_status", expect.anything());
603+
expect(mockSetTag).not.toHaveBeenCalledWith("aws.durable.execution_status", expect.anything());
607604
} finally {
608605
currentSpanSpy.mockRestore();
609606
}

src/trace/listener.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export class TraceListener {
240240
}
241241
const executionStatus = extractDurableExecutionStatus(event, result);
242242
if (executionStatus !== undefined) {
243-
this.tracerWrapper.currentSpan.setTag("aws_lambda.durable_function.execution_status", executionStatus);
243+
this.tracerWrapper.currentSpan.setTag("aws.durable.execution_status", executionStatus);
244244
}
245245

246246
let rootSpan = this.inferredSpan;

0 commit comments

Comments
 (0)