From 417f6f6e276d65920cae88cc3099f7e59fef69d1 Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Wed, 26 Jan 2022 17:04:44 -0800 Subject: [PATCH] HBASE-26472 Adhere to semantic conventions regarding table data operations (addendum) Ensure table data operations emit one and only one span. --- .../hadoop/hbase/client/TestAsyncTableTracing.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java index 8df074e68e43..ae3bc3a00319 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableTracing.java @@ -29,6 +29,7 @@ import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; @@ -41,9 +42,11 @@ import io.opentelemetry.sdk.trace.data.SpanData; import java.io.IOException; import java.util.Arrays; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.Cell.Type; @@ -251,11 +254,12 @@ private void assertTrace(String tableOperation, Matcher matcher) { Waiter.waitFor(CONF, 1000, new MatcherPredicate<>( "waiting for span to emit", () -> traceRule.getSpans(), hasItem(spanLocator))); - SpanData data = traceRule.getSpans() + List candidateSpans = traceRule.getSpans() .stream() .filter(spanLocator::matches) - .findFirst() - .orElseThrow(AssertionError::new); + .collect(Collectors.toList()); + assertThat(candidateSpans, hasSize(1)); + SpanData data = candidateSpans.iterator().next(); assertThat(data, allOf( hasName(expectedName), hasKind(SpanKind.CLIENT),