@@ -49,8 +49,7 @@ const getTraceIds = async (
49
49
) ;
50
50
}
51
51
52
- const ids = [ ] ;
53
-
52
+ const ids : string [ ] = [ ] ;
54
53
for ( const summary of summaries ) {
55
54
if ( summary . Id === undefined ) {
56
55
throw new Error (
@@ -83,10 +82,14 @@ const retriableGetTraceIds = (options: GetXRayTraceIdsOptions) =>
83
82
endTime . getTime ( ) / 1000
84
83
) } --filter-expression 'resource.arn ENDSWITH ":function:${ options . resourceName } "'`
85
84
) ;
85
+
86
+ throw new Error (
87
+ `Failed to get trace IDs after ${ retryOptions . retries } attempts`
88
+ ) ;
86
89
}
87
90
retry ( error ) ;
88
91
}
89
- } ) ;
92
+ } , retryOptions ) ;
90
93
91
94
/**
92
95
* Parse and sort the trace segments by start time
@@ -168,13 +171,24 @@ const getTraceDetails = async (
168
171
* @param options - The options to get trace details, including the trace IDs and expected segments count
169
172
*/
170
173
const retriableGetTraceDetails = ( options : GetXRayTraceDetailsOptions ) =>
171
- promiseRetry ( async ( retry ) => {
174
+ promiseRetry ( async ( retry , attempt ) => {
172
175
try {
173
176
return await getTraceDetails ( options ) ;
174
177
} catch ( error ) {
178
+ if ( attempt === retryOptions . retries ) {
179
+ console . log (
180
+ `Manual query: aws xray batch-get-traces --trace-ids ${
181
+ options . traceIds
182
+ } `
183
+ ) ;
184
+
185
+ throw new Error (
186
+ `Failed to get trace details after ${ retryOptions . retries } attempts`
187
+ ) ;
188
+ }
175
189
retry ( error ) ;
176
190
}
177
- } ) ;
191
+ } , retryOptions ) ;
178
192
179
193
/**
180
194
* Find the main function segment in the trace identified by the `## index.` suffix
@@ -292,7 +306,7 @@ const getTraces = async (
292
306
293
307
const { resourceName } = options ;
294
308
295
- const mainSubsegments = [ ] ;
309
+ const mainSubsegments : EnrichedXRayTraceDocumentParsed [ ] = [ ] ;
296
310
for ( const trace of traces ) {
297
311
const mainSubsegment = findPowertoolsFunctionSegment ( trace , resourceName ) ;
298
312
const enrichedMainSubsegment = {
@@ -319,7 +333,7 @@ const getTracesWithoutMainSubsegments = async (
319
333
320
334
const { resourceName } = options ;
321
335
322
- const lambdaFunctionSegments = [ ] ;
336
+ const lambdaFunctionSegments : EnrichedXRayTraceDocumentParsed [ ] = [ ] ;
323
337
for ( const trace of traces ) {
324
338
const functionSegment = trace . Segments . find (
325
339
( segment ) => segment . Document . origin === 'AWS::Lambda::Function'
0 commit comments