Skip to content

Commit d63f6d6

Browse files
authored
Fix flaky @WithSpan test (#13562)
1 parent 5dfd006 commit d63f6d6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/test/java/io/opentelemetry/test/annotation/WithSpanInstrumentationTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.opentelemetry.test.annotation;
77

88
import static io.opentelemetry.api.common.AttributeKey.stringKey;
9+
import static io.opentelemetry.instrumentation.testing.util.TelemetryDataUtil.orderByRootSpanName;
910
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
1011
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
1112
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
@@ -112,7 +113,8 @@ void multipleSpans() {
112113
void multipleSpansWithoutParent() {
113114
new TracedWithSpan().consumer();
114115

115-
testing.waitAndAssertTraces(
116+
testing.waitAndAssertSortedTraces(
117+
orderByRootSpanName("TracedWithSpan.consumer", "TracedWithSpan.withoutParent"),
116118
trace ->
117119
trace.hasSpansSatisfyingExactly(
118120
span ->

instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/InstrumentationWithSpanAspectTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static io.opentelemetry.api.common.AttributeKey.stringKey;
99
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
1010
import static io.opentelemetry.api.trace.SpanKind.INTERNAL;
11+
import static io.opentelemetry.instrumentation.testing.util.TelemetryDataUtil.orderByRootSpanName;
1112
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
1213
import static io.opentelemetry.sdk.testing.assertj.TracesAssert.assertThat;
1314
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
@@ -189,7 +190,8 @@ void withSpanWithoutParent() {
189190
testing.runWithSpan("parent", withSpanTester::testWithoutParentSpan);
190191

191192
// then
192-
testing.waitAndAssertTraces(
193+
testing.waitAndAssertSortedTraces(
194+
orderByRootSpanName("parent", unproxiedTesterSimpleClassName + ".testWithoutParentSpan"),
193195
trace -> trace.hasSpansSatisfyingExactly(span -> span.hasName("parent").hasKind(INTERNAL)),
194196
trace ->
195197
trace.hasSpansSatisfyingExactly(

0 commit comments

Comments
 (0)