@@ -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,15 @@ 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 for ${ options . resourceName } after ${ retryOptions . retries } retries` ,
88
+ { cause : error }
89
+ ) ;
86
90
}
87
91
retry ( error ) ;
88
92
}
89
- } ) ;
93
+ } , retryOptions ) ;
90
94
91
95
/**
92
96
* Parse and sort the trace segments by start time
@@ -168,13 +172,25 @@ const getTraceDetails = async (
168
172
* @param options - The options to get trace details, including the trace IDs and expected segments count
169
173
*/
170
174
const retriableGetTraceDetails = ( options : GetXRayTraceDetailsOptions ) =>
171
- promiseRetry ( async ( retry ) => {
175
+ promiseRetry ( async ( retry , attempt ) => {
172
176
try {
173
177
return await getTraceDetails ( options ) ;
174
178
} catch ( error ) {
179
+ if ( attempt === retryOptions . retries ) {
180
+ console . log (
181
+ `Manual query: aws xray get-trace-summaries --start-time ${
182
+ options . traceIds
183
+ } `
184
+ ) ;
185
+
186
+ throw new Error (
187
+ `Failed to get trace details for ${ options . traceIds } after ${ retryOptions . retries } retries` ,
188
+ { cause : error }
189
+ ) ;
190
+ }
175
191
retry ( error ) ;
176
192
}
177
- } ) ;
193
+ } , retryOptions ) ;
178
194
179
195
/**
180
196
* Find the main function segment in the trace identified by the `## index.` suffix
@@ -292,7 +308,7 @@ const getTraces = async (
292
308
293
309
const { resourceName } = options ;
294
310
295
- const mainSubsegments = [ ] ;
311
+ const mainSubsegments : EnrichedXRayTraceDocumentParsed [ ] = [ ] ;
296
312
for ( const trace of traces ) {
297
313
const mainSubsegment = findPowertoolsFunctionSegment ( trace , resourceName ) ;
298
314
const enrichedMainSubsegment = {
@@ -319,7 +335,7 @@ const getTracesWithoutMainSubsegments = async (
319
335
320
336
const { resourceName } = options ;
321
337
322
- const lambdaFunctionSegments = [ ] ;
338
+ const lambdaFunctionSegments : EnrichedXRayTraceDocumentParsed [ ] = [ ] ;
323
339
for ( const trace of traces ) {
324
340
const functionSegment = trace . Segments . find (
325
341
( segment ) => segment . Document . origin === 'AWS::Lambda::Function'
0 commit comments