Skip to content

Commit 76f5cbd

Browse files
SilanHehsilan
andauthored
feat(sdk): Add executionStartTimestamp to InvocationBaseInfo (#719)
*Issue #, if available:* *Description of changes:* 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 (should always be available). Updated all test fixtures constructing InvocationInfo or InvocationEndInfo to include the new field. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. Co-authored-by: hsilan <hsilan@amazon.com>
1 parent 46ffaad commit 76f5cbd

6 files changed

Lines changed: 22 additions & 1 deletion

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 timestamp when the overall durable execution was first started,
126+
* as reported by the backend. This remains the same across all
127+
* invocations (including replays) of a given execution.
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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ const mockTerminationManager = {
3939
setCheckpointTerminatingCallback: jest.fn(),
4040
};
4141
const mockExecutionContext = {
42-
_stepData: {},
42+
_stepData: {
43+
"initial-op": {
44+
StartTimestamp: new Date("2024-06-01T12:00:00Z"),
45+
ExecutionDetails: {
46+
InputPayload: "{}",
47+
},
48+
},
49+
},
4350
durableExecutionArn: "arn:test",
4451
requestId: "req-123",
4552
terminationManager: mockTerminationManager,
@@ -89,6 +96,7 @@ describe("plugin hooks", () => {
8996
executionInput: expect.anything(),
9097
operations: expect.any(Object),
9198
updatedOperations: expect.any(Object),
99+
executionStartTimestamp: new Date("2024-06-01T12:00:00Z"),
92100
});
93101
});
94102

@@ -111,6 +119,7 @@ describe("plugin hooks", () => {
111119
executionInput: expect.anything(),
112120
operations: expect.any(Object),
113121
updatedOperations: expect.any(Object),
122+
executionStartTimestamp: new Date("2024-06-01T12:00:00Z"),
114123
});
115124
});
116125

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ async function runHandler<
9595
executionArn: executionContext.durableExecutionArn,
9696
executionInput: customerHandlerEvent,
9797
operations: allOperations,
98+
executionStartTimestamp: initialExecutionEvent?.StartTimestamp ?? undefined,
9899
};
99100

100101
const invocationInfo: InvocationInfo = {

0 commit comments

Comments
 (0)