Skip to content

Commit ab78a70

Browse files
committed
chore: simplify further
1 parent a264cca commit ab78a70

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

packages/testing/src/xray-traces-utils.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ const retriableGetTraceIds = (options: GetXRayTraceIdsOptions) =>
9090
/**
9191
* Get the trace details for a given trace ID from the AWS X-Ray API.
9292
*
93-
* When the trace is returned, the segments are parsed, since the document is returned
94-
* stringified, and then sorted by start time.
93+
* When the trace is returned, the segments are parsed, since the document is returned as a string.
9594
*
9695
* @param options - The options to get trace details, including the trace IDs and expected segments count
9796
*/
@@ -113,7 +112,7 @@ const getTraceDetails = async (
113112
);
114113
}
115114

116-
const parsedAndSortedTraces: XRayTraceParsed[] = [];
115+
const parsedTraces: XRayTraceParsed[] = [];
117116
for (const trace of traces) {
118117
const { Id: id, Segments: segments } = trace;
119118
if (segments === undefined || segments.length !== expectedSegmentsCount) {
@@ -136,20 +135,14 @@ const getTraceDetails = async (
136135
Document: JSON.parse(Document) as XRayTraceDocumentParsed,
137136
});
138137
}
139-
const sortedSegments = parsedSegments.sort(
140-
(a, b) => a.Document.start_time - b.Document.start_time
141-
);
142138

143-
parsedAndSortedTraces.push({
139+
parsedTraces.push({
144140
Id: id as string,
145-
Segments: sortedSegments,
141+
Segments: parsedSegments,
146142
});
147143
}
148144

149-
return parsedAndSortedTraces.sort(
150-
(a, b) =>
151-
a.Segments[0].Document.start_time - b.Segments[0].Document.start_time
152-
);
145+
return parsedTraces;
153146
};
154147

155148
/**

0 commit comments

Comments
 (0)