Skip to content

Commit c726f30

Browse files
authored
Redrive Trace Merging Fix (#605)
Account for missing redrive count in Step Functions trace merging. While we expect the context object to always have `Execution.RedriveCount`, some customers context objects don't have this value.
1 parent 8438492 commit c726f30

File tree

3 files changed

+1
-13
lines changed

3 files changed

+1
-13
lines changed

src/trace/context/extractors/step-function.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ describe("StepFunctionEventTraceExtractor", () => {
1313
RoleArn:
1414
"arn:aws:iam::425362996713:role/service-role/StepFunctions-abhinav-activity-state-machine-role-22jpbgl6j",
1515
StartTime: "2024-12-04T19:38:04.069Z",
16-
RedriveCount: 0,
1716
},
1817
State: {
1918
Name: "Lambda Invoke",

src/trace/step-function-service.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,6 @@ describe("StepFunctionContextService", () => {
109109
},
110110
},
111111
],
112-
[
113-
"Execution RedriveCount is not a number",
114-
{
115-
...legacyStepFunctionEvent,
116-
Execution: {
117-
...legacyStepFunctionEvent.Execution,
118-
RedriveCount: "0",
119-
},
120-
},
121-
],
122112
[
123113
"State is not defined",
124114
{

src/trace/step-function-service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class StepFunctionContextService {
215215
if (this.isValidContextObject(event)) {
216216
return {
217217
execution_id: event.Execution.Id,
218-
redrive_count: event.Execution.RedriveCount.toString(),
218+
redrive_count: (event.Execution.RedriveCount ?? "0").toString(),
219219
state_entered_time: event.State.EnteredTime,
220220
state_name: event.State.Name,
221221
};
@@ -228,7 +228,6 @@ export class StepFunctionContextService {
228228
private isValidContextObject(context: any): boolean {
229229
return (
230230
typeof context?.Execution?.Id === "string" &&
231-
typeof context?.Execution?.RedriveCount === "number" &&
232231
typeof context?.State?.EnteredTime === "string" &&
233232
typeof context?.State?.Name === "string"
234233
);

0 commit comments

Comments
 (0)