Skip to content

Commit a1fb938

Browse files
committed
fix ut
1 parent b1f274d commit a1fb938

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,18 +1035,26 @@ void requestClientError() throws Exception {
10351035

10361036
URI uri = resolveAddress("/client-error");
10371037
String method = "GET";
1038-
int responseCode = doRequest(method, uri);
10391038

1040-
assertThat(responseCode).isEqualTo(400);
1039+
testing.runWithSpan(
1040+
"parent",
1041+
() -> {
1042+
try {
1043+
doRequest(method, uri);
1044+
} catch (Throwable ignored) {
1045+
// ignored
1046+
}
1047+
});
10411048

10421049
testing.waitAndAssertTraces(
10431050
trace ->
10441051
trace.hasSpansSatisfyingExactly(
1052+
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
10451053
span ->
10461054
assertClientSpan(span, uri, method, 400, null)
1047-
.hasNoParent()
1055+
.hasParent(trace.getSpan(0))
10481056
.hasStatus(StatusData.error()),
1049-
span -> assertServerSpan(span).hasParent(trace.getSpan(0))));
1057+
span -> assertServerSpan(span).hasParent(trace.getSpan(1))));
10501058
}
10511059

10521060
// Visible for spock bridge.

0 commit comments

Comments
 (0)