Skip to content

Commit 90218d7

Browse files
committed
Add retries for custom subsegment population.
1 parent 1c4dccc commit 90218d7

File tree

1 file changed

+7
-1
lines changed
  • powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/tracing

1 file changed

+7
-1
lines changed

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/tracing/TraceFetcher.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private Trace getTrace(List<String> traceIds) {
109109
if (!tracesResponse.hasTraces()) {
110110
throw new TraceNotFoundException(String.format("No trace found for traceIds %s", traceIds));
111111
}
112-
112+
113113
Trace traceRes = new Trace();
114114
tracesResponse.traces().forEach(trace -> {
115115
if (trace.hasSegments()) {
@@ -119,6 +119,12 @@ private Trace getTrace(List<String> traceIds) {
119119
if ("AWS::Lambda::Function".equals(document.getOrigin()) && document.hasSubsegments()) {
120120
LOG.debug("Populating subsegments for document {}", MAPPER.writeValueAsString(document));
121121
getNestedSubSegments(document.getSubsegments(), traceRes, Collections.emptyList());
122+
// If only the default (excluded) subsegments were populated we need to keep retrying for
123+
// our custom subsegments. They might appear later.
124+
if (traceRes.getSubsegments().isEmpty()) {
125+
throw new TraceNotFoundException(
126+
"Found AWS::Lambda::Function SegmentDocument with no non-excluded subsegments.");
127+
}
122128
} else if ("AWS::Lambda::Function".equals(document.getOrigin())) {
123129
LOG.debug(
124130
"Found AWS::Lambda::Function SegmentDocument with no subsegments. Retrying {}",

0 commit comments

Comments
 (0)