Skip to content

Commit

Permalink
Second attempt at fixing flaky spring rabbit test (#9809)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Nov 6, 2023
1 parent dbe90c5 commit f811bf6
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.semconv.SemanticAttributes;
import java.time.Duration;
import java.util.ArrayList;
Expand Down Expand Up @@ -178,7 +179,27 @@ public void test(boolean testHeaders) throws Exception {
.hasParent(trace.getSpan(1))
.hasAttributesSatisfyingExactly(
getAssertions("testQueue", "process", null, false, testHeaders)),
span -> span.hasName("consumer").hasParent(trace.getSpan(3)));
span -> {
// occasionally "testQueue process" spans have their order swapped, usually
// it would be
// 0 - parent
// 1 - <default> publish
// 2 - testQueue process (<default>)
// 3 - testQueue process (testQueue)
// 4 - consumer
// but it could also be
// 0 - parent
// 1 - <default> publish
// 2 - testQueue process (testQueue)
// 3 - consumer
// 4 - testQueue process (<default>)
// determine the correct parent span based on the span name
SpanData parentSpan = trace.getSpan(3);
if (!"testQueue process".equals(parentSpan.getName())) {
parentSpan = trace.getSpan(2);
}
span.hasName("consumer").hasParent(parentSpan);
});
},
trace -> {
trace
Expand Down

0 comments on commit f811bf6

Please sign in to comment.