Skip to content

Commit 0ba26c3

Browse files
authored
Change event details order to enhance discovery (#955)
* Change event details order to enhance discovery * unify string default value and change unimportant to unneeded * update snapshot
1 parent 3a0eac7 commit 0ba26c3

File tree

39 files changed

+174
-104
lines changed

39 files changed

+174
-104
lines changed

src/utils/data-formatters/format-pending-workflow-history-event/__tests__/index.test.ts.snapshot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports[`formatWorkflowHistoryEvent should format workflow pendingActivityTaskSt
1616
"workflow.sanity",
1717
],
1818
"lastFailureDetails": null,
19-
"lastFailureReason": "",
19+
"lastFailureReason": null,
2020
"lastHeartbeatTime": null,
2121
"lastStartedTime": null,
2222
"lastWorkerIdentity": "",
@@ -44,7 +44,7 @@ exports[`formatWorkflowHistoryEvent should format workflow pendingActivityTaskSt
4444
"workflow.sanity",
4545
],
4646
"lastFailureDetails": null,
47-
"lastFailureReason": "",
47+
"lastFailureReason": null,
4848
"lastHeartbeatTime": null,
4949
"lastStartedTime": 2024-09-07T22:16:10.599Z,
5050
"lastWorkerIdentity": "",
@@ -72,7 +72,7 @@ exports[`formatWorkflowHistoryEvent should format workflow pendingActivityTaskSt
7272
"workflow.sanity",
7373
],
7474
"lastFailureDetails": null,
75-
"lastFailureReason": "",
75+
"lastFailureReason": null,
7676
"lastHeartbeatTime": null,
7777
"lastStartedTime": 2024-09-07T22:16:10.599Z,
7878
"lastWorkerIdentity": "",

src/utils/data-formatters/format-pending-workflow-history-event/format-pending-activity-start-event.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ export default function formatPendingActivityTaskStartEvent({
2020
eventTime,
2121
}: PendingActivityTaskStartEvent) {
2222
return {
23-
...eventAttributes,
2423
eventTime: formatTimestampToDatetime(eventTime),
2524
eventType: 'PendingActivityTaskStart',
25+
...eventAttributes,
2626
state: formatEnum(state, 'PENDING_ACTIVITY_STATE', 'pascal'),
27-
scheduleId: parseInt(scheduleId),
27+
lastFailureDetails: formatFailureDetails(lastFailure),
28+
lastFailureReason: lastFailure?.reason || null,
29+
heartbeatDetails: formatPayload(heartbeatDetails),
30+
scheduledTime: formatTimestampToDatetime(scheduledTime),
2831
lastHeartbeatTime: formatTimestampToDatetime(lastHeartbeatTime),
2932
lastStartedTime: formatTimestampToDatetime(lastStartedTime),
30-
scheduledTime: formatTimestampToDatetime(scheduledTime),
3133
expirationTime: formatTimestampToDatetime(expirationTime),
32-
heartbeatDetails: formatPayload(heartbeatDetails),
33-
lastFailureDetails: formatFailureDetails(lastFailure),
34-
lastFailureReason: lastFailure?.reason,
34+
scheduleId: parseInt(scheduleId),
3535
};
3636
}

src/utils/data-formatters/format-workflow-history-event/__tests__/index.test.ts.snapshot

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ exports[`formatWorkflowHistoryEvent should format workflow activityTaskFailedEve
4747
"eventId": 11,
4848
"eventType": "ActivityTaskFailed",
4949
"identity": "cadence@958ab341-a376-431n-a17a-ed7d8a97ba91",
50-
"reason": "",
50+
"reason": null,
5151
"scheduledEventId": 7,
5252
"startedEventId": 9,
5353
"taskId": "22647174813",
@@ -98,7 +98,7 @@ exports[`formatWorkflowHistoryEvent should format workflow activityTaskStartedEv
9898
"eventType": "ActivityTaskStarted",
9999
"identity": "cadence@958ab341-a375-431b-a17a-ed7d8a97ba91",
100100
"lastFailureDetails": null,
101-
"lastFailureReason": "",
101+
"lastFailureReason": null,
102102
"requestId": "27e61b29-7rc9-48f4-9e78-0366e9ffd413",
103103
"scheduledEventId": 7,
104104
"taskId": "22647174807",
@@ -113,7 +113,7 @@ exports[`formatWorkflowHistoryEvent should format workflow activityTaskTimedOutE
113113
"eventId": 12,
114114
"eventType": "ActivityTaskTimedOut",
115115
"lastFailureDetails": null,
116-
"lastFailureReason": "",
116+
"lastFailureReason": null,
117117
"scheduledEventId": 7,
118118
"startedEventId": 9,
119119
"taskId": "22647174813",
@@ -186,7 +186,7 @@ exports[`formatWorkflowHistoryEvent should format workflow childWorkflowExecutio
186186
"eventId": 47,
187187
"eventType": "ChildWorkflowExecutionFailed",
188188
"initiatedEventId": 40,
189-
"reason": "",
189+
"reason": null,
190190
"startedEventId": 42,
191191
"taskId": "5877269789",
192192
"timestamp": 2024-09-08T04:27:58.993Z,
@@ -269,7 +269,7 @@ exports[`formatWorkflowHistoryEvent should format workflow decisionTaskCompleted
269269
"binaryChecksum": "cadence:eb16a90a9182002897d7a6c6585871eedace71d1",
270270
"eventId": 4,
271271
"eventType": "DecisionTaskCompleted",
272-
"executionContext": "",
272+
"executionContext": null,
273273
"identity": "cadence@958ab342-a376-431b-a17a-ed7d8a97ba91",
274274
"scheduledEventId": "2",
275275
"startedEventId": "3",
@@ -290,7 +290,7 @@ exports[`formatWorkflowHistoryEvent should format workflow decisionTaskFailedEve
290290
"forkEventVersion": 0,
291291
"identity": "cadence@958ab341-a375-431b-a27a-ed7d8a97ba91",
292292
"newRunId": "",
293-
"reason": "",
293+
"reason": null,
294294
"requestId": "66f7f58b-3d3b-4178-972a-fa7825ceec39",
295295
"scheduledEventId": 2,
296296
"startedEventId": 3,
@@ -511,7 +511,7 @@ exports[`formatWorkflowHistoryEvent should format workflow startChildWorkflowExe
511511
exports[`formatWorkflowHistoryEvent should format workflow startChildWorkflowExecutionInitiatedEventAttributes to match snapshot 1`] = `
512512
{
513513
"control": null,
514-
"cronSchedule": "",
514+
"cronSchedule": null,
515515
"decisionTaskCompletedEventId": 4,
516516
"delayStartSeconds": null,
517517
"domain": "cadence-domain",
@@ -654,7 +654,7 @@ exports[`formatWorkflowHistoryEvent should format workflow workflowExecutionCont
654654
"eventType": "WorkflowExecutionContinuedAsNew",
655655
"executionStartToCloseTimeoutSeconds": 1080,
656656
"failureDetails": null,
657-
"failureReason": "",
657+
"failureReason": null,
658658
"header": {
659659
"fields": {},
660660
},

src/utils/data-formatters/format-workflow-history-event/format-activity-task-canceled-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ const formatActivityTaskCanceledEvent = ({
1515
}: ActivityTaskCanceledEvent) => {
1616
return {
1717
...formatWorkflowCommonEventFields(eventFields),
18-
...eventAttributes,
1918
details: formatPayload(details),
2019
latestCancelRequestedEventId: parseInt(latestCancelRequestedEventId),
2120
scheduledEventId: parseInt(scheduledEventId),
2221
startedEventId: parseInt(startedEventId),
22+
...eventAttributes,
2323
};
2424
};
2525

src/utils/data-formatters/format-workflow-history-event/format-activity-task-completed-event.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ const formatActivityTaskCompletedEvent = ({
88
result,
99
scheduledEventId,
1010
startedEventId,
11+
identity,
1112
...eventAttributes
1213
},
1314
...eventFields
1415
}: ActivityTaskCompletedEvent) => {
1516
return {
1617
...formatWorkflowCommonEventFields(eventFields),
17-
...eventAttributes,
1818
result: formatPayload(result),
19+
identity,
1920
scheduledEventId: parseInt(scheduledEventId),
2021
startedEventId: parseInt(startedEventId),
22+
...eventAttributes,
2123
};
2224
};
2325

src/utils/data-formatters/format-workflow-history-event/format-activity-task-failed-event.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ const formatActivityTaskFailedEvent = ({
88
failure,
99
scheduledEventId,
1010
startedEventId,
11+
identity,
1112
...eventAttributes
1213
},
1314
...eventFields
1415
}: ActivityTaskFailedEvent) => {
1516
return {
1617
...formatWorkflowCommonEventFields(eventFields),
17-
...eventAttributes,
1818
details: formatFailureDetails(failure),
19-
reason: failure?.reason || '',
19+
reason: failure?.reason || null,
20+
identity,
2021
scheduledEventId: parseInt(scheduledEventId),
2122
startedEventId: parseInt(startedEventId),
23+
...eventAttributes,
2224
};
2325
};
2426

src/utils/data-formatters/format-workflow-history-event/format-activity-task-scheduled-event.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ const formatActivityTaskScheduledEvent = ({
2626
return {
2727
...formatWorkflowCommonEventFields(eventFields),
2828
...eventAttributes,
29-
decisionTaskCompletedEventId: parseInt(decisionTaskCompletedEventId),
30-
domain: domain || null,
31-
header: formatPayloadMap(header, 'fields'),
32-
heartbeatTimeoutSeconds: formatDurationToSeconds(heartbeatTimeout),
29+
taskList: {
30+
kind: formatEnum(taskList?.kind, 'TASK_LIST_KIND'),
31+
name: taskList?.name || null,
32+
},
3333
input: formatInputPayload(input),
34+
heartbeatTimeoutSeconds: formatDurationToSeconds(heartbeatTimeout),
3435
retryPolicy: formatRetryPolicy(retryPolicy),
3536
scheduleToCloseTimeoutSeconds: formatDurationToSeconds(
3637
scheduleToCloseTimeout
@@ -39,10 +40,9 @@ const formatActivityTaskScheduledEvent = ({
3940
scheduleToStartTimeout
4041
),
4142
startToCloseTimeoutSeconds: formatDurationToSeconds(startToCloseTimeout),
42-
taskList: {
43-
kind: formatEnum(taskList?.kind, 'TASK_LIST_KIND'),
44-
name: taskList?.name || null,
45-
},
43+
domain: domain || null,
44+
decisionTaskCompletedEventId: parseInt(decisionTaskCompletedEventId),
45+
header: formatPayloadMap(header, 'fields'),
4646
};
4747
};
4848

src/utils/data-formatters/format-workflow-history-event/format-activity-task-started-event.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ const formatActivityTaskStartedEvent = ({
77
activityTaskStartedEventAttributes: {
88
lastFailure,
99
scheduledEventId,
10+
requestId,
11+
identity,
12+
attempt,
1013
...eventAttributes
1114
},
1215
...eventFields
1316
}: ActivityTaskStartedEvent) => {
1417
return {
1518
...formatWorkflowCommonEventFields(eventFields),
16-
...eventAttributes,
1719
lastFailureDetails: formatFailureDetails(lastFailure),
18-
lastFailureReason: lastFailure?.reason || '',
20+
lastFailureReason: lastFailure?.reason || null,
21+
attempt,
22+
identity,
1923
scheduledEventId: parseInt(scheduledEventId),
24+
requestId,
25+
...eventAttributes,
2026
};
2127
};
2228

src/utils/data-formatters/format-workflow-history-event/format-activity-task-timed-out-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const formatActivityTaskTimedOutEvent = ({
2222
timeoutType: formatEnum(timeoutType, 'TIMEOUT_TYPE', 'pascal'),
2323
details: formatPayload(details),
2424
lastFailureDetails: formatFailureDetails(lastFailure),
25-
lastFailureReason: lastFailure?.reason || '',
25+
lastFailureReason: lastFailure?.reason || null,
2626
scheduledEventId: parseInt(scheduledEventId),
2727
startedEventId: parseInt(startedEventId),
2828
};

src/utils/data-formatters/format-workflow-history-event/format-child-workflow-execution-canceled-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const formatChildWorkflowExecutionCanceledEvent = ({
1414
}: ChildWorkflowExecutionCanceledEvent) => {
1515
return {
1616
...formatWorkflowCommonEventFields(eventFields),
17-
...eventAttributes,
1817
details: formatPayload(details),
18+
...eventAttributes,
1919
initiatedEventId: parseInt(initiatedEventId),
2020
startedEventId: parseInt(startedEventId),
2121
};

0 commit comments

Comments
 (0)