@@ -149,21 +149,30 @@ private void getNestedSubSegments(List<SubSegment> subsegments, Trace traceRes,
149149 * @return a list of trace ids
150150 */
151151 private List <String > getTraceIds () {
152+ LOG .debug ("Searching for traces from {} to {} with filter: {}" , start , end , filterExpression );
152153 GetTraceSummariesResponse traceSummaries = xray .getTraceSummaries (GetTraceSummariesRequest .builder ()
153154 .startTime (start )
154155 .endTime (end )
155- .timeRangeType (TimeRangeType .EVENT )
156+ .timeRangeType (TimeRangeType .TRACE_ID )
156157 .sampling (false )
157158 .filterExpression (filterExpression )
158159 .build ());
160+
161+ LOG .debug ("Found {} trace summaries" ,
162+ traceSummaries .hasTraceSummaries () ? traceSummaries .traceSummaries ().size () : 0 );
163+
159164 if (!traceSummaries .hasTraceSummaries ()) {
160- throw new TraceNotFoundException ("No trace id found" );
165+ throw new TraceNotFoundException (String .format ("No trace id found for filter '%s' between %s and %s" ,
166+ filterExpression , start , end ));
161167 }
162168 List <String > traceIds = traceSummaries .traceSummaries ().stream ().map (TraceSummary ::id )
163169 .collect (Collectors .toList ());
164170 if (traceIds .isEmpty ()) {
165- throw new TraceNotFoundException ("No trace id found" );
171+ throw new TraceNotFoundException (
172+ String .format ("Empty trace summary found for filter '%s' between %s and %s" ,
173+ filterExpression , start , end ));
166174 }
175+ LOG .debug ("Found trace IDs: {}" , traceIds );
167176 return traceIds ;
168177 }
169178
@@ -183,9 +192,13 @@ public TraceFetcher build() {
183192 if (end == null ) {
184193 end = start .plus (1 , ChronoUnit .MINUTES );
185194 }
186- LOG .debug ("Looking for traces from {} to {} with filter {} and excluded segments {}" , start , end ,
187- filterExpression , excludedSegments );
188- return new TraceFetcher (start , end , filterExpression , excludedSegments );
195+ // Expand search window by 1 minute on each side to account for timing imprecisions
196+ Instant expandedStart = start .minus (1 , ChronoUnit .MINUTES );
197+ Instant expandedEnd = end .plus (1 , ChronoUnit .MINUTES );
198+ LOG .debug (
199+ "Looking for traces from {} to {} (expanded from {} to {}) with filter {} and excluded segments {}" ,
200+ expandedStart , expandedEnd , start , end , filterExpression , excludedSegments );
201+ return new TraceFetcher (expandedStart , expandedEnd , filterExpression , excludedSegments );
189202 }
190203
191204 public Builder start (Instant start ) {
0 commit comments