Skip to content

Commit 080c630

Browse files
committed
feat(plugin): Add executionStartTimestamp to InvocationBaseInfo
Add optional executionStartTimestamp field to InvocationBaseInfo so it is available on all onInvocation* hook parameters (InvocationInfo and InvocationEndInfo). The timestamp is derived from initialExecutionEvent.StartTimestamp when available. Updated all test fixtures constructing InvocationInfo or InvocationEndInfo to include the new field.
1 parent 000eb3a commit 080c630

6 files changed

Lines changed: 16 additions & 0 deletions

File tree

packages/aws-durable-execution-sdk-js-otel/src/__tests__/context-extractors.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const baseInfo: InvocationInfo = {
1212
executionInput: {},
1313
operations: {},
1414
updatedOperations: {},
15+
executionStartTimestamp: new Date("2024-01-01T00:00:00Z"),
1516
};
1617

1718
describe("xRayContextExtractor", () => {

packages/aws-durable-execution-sdk-js-otel/src/__tests__/plugin.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function makeInvocationInfo(
4242
executionInput: {},
4343
operations: {},
4444
updatedOperations: {},
45+
executionStartTimestamp: new Date("2024-01-01T00:00:00Z"),
4546
...overrides,
4647
};
4748
}
@@ -57,6 +58,7 @@ function makeInvocationEndInfo(
5758
status: "SUCCEEDED" as any,
5859
executionResult: undefined,
5960
executionError: undefined,
61+
executionStartTimestamp: new Date("2024-01-01T00:00:00Z"),
6062
...overrides,
6163
};
6264
}

packages/aws-durable-execution-sdk-js/src/types/plugin.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ export interface InvocationBaseInfo {
121121
executionArn: string;
122122
executionInput: unknown;
123123
operations: Record<string, OperationInfo>;
124+
/**
125+
* The wall-clock time when this Lambda invocation began processing.
126+
* Captured at the start of the durable execution handler, before any
127+
* plugin hooks or user code run.
128+
*/
129+
executionStartTimestamp?: Date;
124130
}
125131

126132
/**

packages/aws-durable-execution-sdk-js/src/utils/plugin/plugin-runner.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe("createPluginRunner", () => {
2828
executionInput: { test: true },
2929
operations: {},
3030
updatedOperations: {},
31+
executionStartTimestamp: new Date("2024-01-01T00:00:00Z"),
3132
};
3233

3334
const operationInfo: OperationInfo = {
@@ -723,6 +724,7 @@ describe("createPluginRunner", () => {
723724
executionResult: { data: "test" },
724725
executionInput: { event: "input" },
725726
operations: {},
727+
executionStartTimestamp: new Date("2024-01-01T00:00:00Z"),
726728
};
727729

728730
it.each([

packages/aws-durable-execution-sdk-js/src/with-durable-execution.plugin.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ describe("plugin hooks", () => {
8989
executionInput: expect.anything(),
9090
operations: expect.any(Object),
9191
updatedOperations: expect.any(Object),
92+
executionStartTimestamp: undefined,
9293
});
9394
});
9495

@@ -111,6 +112,7 @@ describe("plugin hooks", () => {
111112
executionInput: expect.anything(),
112113
operations: expect.any(Object),
113114
updatedOperations: expect.any(Object),
115+
executionStartTimestamp: undefined,
114116
});
115117
});
116118

packages/aws-durable-execution-sdk-js/src/with-durable-execution.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ async function runHandler<
9595
executionArn: executionContext.durableExecutionArn,
9696
executionInput: customerHandlerEvent,
9797
operations: allOperations,
98+
executionStartTimestamp: initialExecutionEvent?.StartTimestamp
99+
? new Date(initialExecutionEvent.StartTimestamp)
100+
: undefined,
98101
};
99102

100103
const invocationInfo: InvocationInfo = {

0 commit comments

Comments
 (0)