Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class ITOtelTracing {
private static final String VALUE_SERVICE_UNAVAILABLE = "Service Unavailable";
private static final String SPAN_NAME_ECHO_GRPC = "google.showcase.v1beta1.Echo/Echo";
private static final String SPAN_NAME_ECHO_HTTP = "POST v1beta1/echo:echo";
private static final String SPAN_NAME_OPERATION_ECHO = "google.showcase.v1beta1.Echo.Echo";
private static final String SPAN_NAME_GET_USER_GRPC = "google.showcase.v1beta1.Identity/GetUser";
private static final String SPAN_NAME_GET_USER_HTTP = "GET v1beta1/{name=users/*}";

Expand Down Expand Up @@ -501,15 +502,25 @@ void testTracing_retry_grpc_linkedToParentContext() throws Exception {
parentSpan.end();
}

List<SpanData> spans = spanExporter.getFinishedSpanItems();
assertThat(spans).hasSize(attempts + 1);
List<SpanData> spans = waitForSpans(attempts + 2);
assertThat(spans).hasSize(attempts + 2);

SpanData rootSpan =
spans.stream()
.filter(span -> span.getName().equals("application-parent-operation"))
.findFirst()
.orElseThrow(() -> new AssertionError("Parent span not found"));

SpanData operationSpan =
spans.stream()
.filter(span -> span.getName().equals(SPAN_NAME_OPERATION_ECHO))
.findFirst()
.orElseThrow(() -> new AssertionError("Operation span not found"));
assertThat(operationSpan.getKind()).isEqualTo(SpanKind.INTERNAL);
assertThat(operationSpan.getParentSpanId()).isEqualTo(rootSpan.getSpanContext().getSpanId());
assertThat(operationSpan.getSpanContext().getTraceId())
.isEqualTo(rootSpan.getSpanContext().getTraceId());

List<SpanData> attemptSpans =
spans.stream()
.filter(span -> span.getName().equals(SPAN_NAME_ECHO_GRPC))
Expand All @@ -518,7 +529,8 @@ void testTracing_retry_grpc_linkedToParentContext() throws Exception {

for (SpanData attemptSpan : attemptSpans) {
assertThat(attemptSpan.getKind()).isEqualTo(SpanKind.CLIENT);
assertThat(attemptSpan.getParentSpanId()).isEqualTo(rootSpan.getSpanContext().getSpanId());
assertThat(attemptSpan.getParentSpanId())
.isEqualTo(operationSpan.getSpanContext().getSpanId());
assertThat(attemptSpan.getSpanContext().getTraceId())
.isEqualTo(rootSpan.getSpanContext().getTraceId());
}
Expand Down Expand Up @@ -642,15 +654,25 @@ void testTracing_retry_httpjson_linkedToParentContext() throws Exception {
parentSpan.end();
}

List<SpanData> spans = spanExporter.getFinishedSpanItems();
assertThat(spans).hasSize(attempts + 1);
List<SpanData> spans = waitForSpans(attempts + 2);
assertThat(spans).hasSize(attempts + 2);

SpanData rootSpan =
spans.stream()
.filter(span -> span.getName().equals("application-parent-operation"))
.findFirst()
.orElseThrow(() -> new AssertionError("Parent span not found"));

SpanData operationSpan =
spans.stream()
.filter(span -> span.getName().equals(SPAN_NAME_OPERATION_ECHO))
.findFirst()
.orElseThrow(() -> new AssertionError("Operation span not found"));
assertThat(operationSpan.getKind()).isEqualTo(SpanKind.INTERNAL);
assertThat(operationSpan.getParentSpanId()).isEqualTo(rootSpan.getSpanContext().getSpanId());
assertThat(operationSpan.getSpanContext().getTraceId())
.isEqualTo(rootSpan.getSpanContext().getTraceId());

List<SpanData> attemptSpans =
spans.stream()
.filter(span -> span.getName().equals(SPAN_NAME_ECHO_HTTP))
Expand All @@ -659,7 +681,8 @@ void testTracing_retry_httpjson_linkedToParentContext() throws Exception {

for (SpanData attemptSpan : attemptSpans) {
assertThat(attemptSpan.getKind()).isEqualTo(SpanKind.CLIENT);
assertThat(attemptSpan.getParentSpanId()).isEqualTo(rootSpan.getSpanContext().getSpanId());
assertThat(attemptSpan.getParentSpanId())
.isEqualTo(operationSpan.getSpanContext().getSpanId());
assertThat(attemptSpan.getSpanContext().getTraceId())
.isEqualTo(rootSpan.getSpanContext().getTraceId());
}
Expand Down
Loading