|
29 | 29 | import static org.hamcrest.Matchers.allOf; |
30 | 30 | import static org.hamcrest.Matchers.containsString; |
31 | 31 | import static org.hamcrest.Matchers.hasItem; |
| 32 | +import static org.hamcrest.Matchers.hasSize; |
32 | 33 | import static org.junit.Assert.fail; |
33 | 34 | import static org.mockito.ArgumentMatchers.any; |
34 | 35 | import static org.mockito.ArgumentMatchers.anyInt; |
|
41 | 42 | import io.opentelemetry.sdk.trace.data.SpanData; |
42 | 43 | import java.io.IOException; |
43 | 44 | import java.util.Arrays; |
| 45 | +import java.util.List; |
44 | 46 | import java.util.concurrent.CompletableFuture; |
45 | 47 | import java.util.concurrent.ForkJoinPool; |
46 | 48 | import java.util.concurrent.atomic.AtomicInteger; |
| 49 | +import java.util.stream.Collectors; |
47 | 50 | import org.apache.hadoop.conf.Configuration; |
48 | 51 | import org.apache.hadoop.hbase.Cell; |
49 | 52 | import org.apache.hadoop.hbase.Cell.Type; |
@@ -251,11 +254,12 @@ private void assertTrace(String tableOperation, Matcher<SpanData> matcher) { |
251 | 254 | Waiter.waitFor(CONF, 1000, new MatcherPredicate<>( |
252 | 255 | "waiting for span to emit", |
253 | 256 | () -> traceRule.getSpans(), hasItem(spanLocator))); |
254 | | - SpanData data = traceRule.getSpans() |
| 257 | + List<SpanData> candidateSpans = traceRule.getSpans() |
255 | 258 | .stream() |
256 | 259 | .filter(spanLocator::matches) |
257 | | - .findFirst() |
258 | | - .orElseThrow(AssertionError::new); |
| 260 | + .collect(Collectors.toList()); |
| 261 | + assertThat(candidateSpans, hasSize(1)); |
| 262 | + SpanData data = candidateSpans.iterator().next(); |
259 | 263 | assertThat(data, allOf( |
260 | 264 | hasName(expectedName), |
261 | 265 | hasKind(SpanKind.CLIENT), |
|
0 commit comments