Fix flaky @WithSpan test (#13562)
This commit is contained in:
parent
5dfd0068c5
commit
d63f6d6e6d
|
@ -6,6 +6,7 @@
|
||||||
package io.opentelemetry.test.annotation;
|
package io.opentelemetry.test.annotation;
|
||||||
|
|
||||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||||
|
import static io.opentelemetry.instrumentation.testing.util.TelemetryDataUtil.orderByRootSpanName;
|
||||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
|
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
|
||||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
|
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
|
||||||
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
|
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
|
||||||
|
@ -112,7 +113,8 @@ class WithSpanInstrumentationTest {
|
||||||
void multipleSpansWithoutParent() {
|
void multipleSpansWithoutParent() {
|
||||||
new TracedWithSpan().consumer();
|
new TracedWithSpan().consumer();
|
||||||
|
|
||||||
testing.waitAndAssertTraces(
|
testing.waitAndAssertSortedTraces(
|
||||||
|
orderByRootSpanName("TracedWithSpan.consumer", "TracedWithSpan.withoutParent"),
|
||||||
trace ->
|
trace ->
|
||||||
trace.hasSpansSatisfyingExactly(
|
trace.hasSpansSatisfyingExactly(
|
||||||
span ->
|
span ->
|
||||||
|
|
|
@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumen
|
||||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||||
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
|
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
|
||||||
import static io.opentelemetry.api.trace.SpanKind.INTERNAL;
|
import static io.opentelemetry.api.trace.SpanKind.INTERNAL;
|
||||||
|
import static io.opentelemetry.instrumentation.testing.util.TelemetryDataUtil.orderByRootSpanName;
|
||||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
|
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
|
||||||
import static io.opentelemetry.sdk.testing.assertj.TracesAssert.assertThat;
|
import static io.opentelemetry.sdk.testing.assertj.TracesAssert.assertThat;
|
||||||
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
|
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
|
||||||
|
@ -189,7 +190,8 @@ class InstrumentationWithSpanAspectTest {
|
||||||
testing.runWithSpan("parent", withSpanTester::testWithoutParentSpan);
|
testing.runWithSpan("parent", withSpanTester::testWithoutParentSpan);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
testing.waitAndAssertTraces(
|
testing.waitAndAssertSortedTraces(
|
||||||
|
orderByRootSpanName("parent", unproxiedTesterSimpleClassName + ".testWithoutParentSpan"),
|
||||||
trace -> trace.hasSpansSatisfyingExactly(span -> span.hasName("parent").hasKind(INTERNAL)),
|
trace -> trace.hasSpansSatisfyingExactly(span -> span.hasName("parent").hasKind(INTERNAL)),
|
||||||
trace ->
|
trace ->
|
||||||
trace.hasSpansSatisfyingExactly(
|
trace.hasSpansSatisfyingExactly(
|
||||||
|
|
Loading…
Reference in New Issue