Skip to content

Commit 4f31750

Browse files
committed
update context.input format
1 parent 1e6a582 commit 4f31750

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

src/trace/context.spec.ts

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,12 @@ describe("readTraceFromLambdaContext", () => {
667667
});
668668

669669
describe("readStepFunctionContextFromEvent", () => {
670-
const stepFunctionEventWithoutInput = {
670+
const stepFunctionEvent = {
671671
Execution: {
672672
Id: "arn:aws:states:sa-east-1:425362996713:express:logs-to-traces-sequential:85a9933e-9e11-83dc-6a61-b92367b6c3be:3f7ef5c7-c8b8-4c88-90a1-d54aa7e7e2bf",
673+
Input: {
674+
MyInput: "MyValue"
675+
},
673676
Name: "85a9933e-9e11-83dc-6a61-b92367b6c3be",
674677
RoleArn: "arn:aws:iam::425362996713:role/service-role/StepFunctions-logs-to-traces-sequential-role-ccd69c03",
675678
StartTime: "2022-12-08T21:08:17.924Z",
@@ -685,31 +688,6 @@ describe("readStepFunctionContextFromEvent", () => {
685688
},
686689
} as const;
687690

688-
const stepFunctionEvent = {
689-
...stepFunctionEventWithoutInput,
690-
Execution: {
691-
...stepFunctionEventWithoutInput.Execution,
692-
Input: {
693-
MyInput: "MyValue"
694-
}
695-
}
696-
} as const;
697-
698-
it("reads a step function context from event without Execution.Input", () => {
699-
const result = readStepFunctionContextFromEvent(stepFunctionEventWithoutInput);
700-
expect(result).toEqual({
701-
"step_function.execution_id": "arn:aws:states:sa-east-1:425362996713:express:logs-to-traces-sequential:85a9933e-9e11-83dc-6a61-b92367b6c3be:3f7ef5c7-c8b8-4c88-90a1-d54aa7e7e2bf",
702-
"step_function.execution_input": null,
703-
"step_function.execution_name": "85a9933e-9e11-83dc-6a61-b92367b6c3be",
704-
"step_function.execution_role_arn": "arn:aws:iam::425362996713:role/service-role/StepFunctions-logs-to-traces-sequential-role-ccd69c03",
705-
"step_function.execution_start_time": "2022-12-08T21:08:17.924Z",
706-
"step_function.state_entered_time": "2022-12-08T21:08:19.224Z",
707-
"step_function.state_machine_arn": "arn:aws:states:sa-east-1:425362996713:stateMachine:logs-to-traces-sequential",
708-
"step_function.state_machine_name": "my-state-machine",
709-
"step_function.state_name": "step-one",
710-
"step_function.state_retry_count": 2,
711-
});
712-
});
713691
it("reads a step function context from event with Execution.Input", () => {
714692
const result = readStepFunctionContextFromEvent(stepFunctionEvent);
715693
expect(result).toEqual({

src/trace/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface TraceContext {
5252
export interface StepFunctionContext {
5353
"step_function.execution_name": string,
5454
"step_function.execution_id": string,
55-
"step_function.execution_input": string | object,
55+
"step_function.execution_input": object,
5656
"step_function.execution_role_arn": string,
5757
"step_function.execution_start_time": string,
5858
"step_function.state_machine_name": string;
@@ -565,7 +565,7 @@ export function readStepFunctionContextFromEvent(event: any): StepFunctionContex
565565
return {
566566
"step_function.execution_name": executionName,
567567
"step_function.execution_id": executionID,
568-
"step_function.execution_input": executionInput ?? null,
568+
"step_function.execution_input": executionInput ?? {},
569569
"step_function.execution_role_arn": executionRoleArn,
570570
"step_function.execution_start_time": executionStartTime,
571571
"step_function.state_entered_time": stateEnteredTime,

0 commit comments

Comments
 (0)