Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed OpentraceableClientE2ETest to be more deterministic #5536

Merged
merged 2 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
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 @@ -25,6 +25,8 @@
import io.helidon.logging.common.LogConfig;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static java.lang.System.Logger.Level.INFO;
Expand All @@ -42,14 +44,19 @@ class BulkheadTest {

private static final long WAIT_TIMEOUT_MILLIS = 10000;

private final CountDownLatch enqueuedSubmitted = new CountDownLatch(1);
private CountDownLatch enqueuedSubmitted;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is done to allow @RepeatedTest to be used on testBulkhead to reproduce intermittent failure


@BeforeAll
static void setupTest() {
LogConfig.configureRuntime();
}

@Test
@BeforeEach
void resetLatch() {
enqueuedSubmitted = new CountDownLatch(1);
}

@Disabled
void testBulkhead() throws InterruptedException, ExecutionException, java.util.concurrent.TimeoutException {
// Create bulkhead of 1 with queue length 1
String name = "unit:testBulkhead";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,13 @@ private void doAccept(ServerRequest req, ServerResponse res) {

String spanName = spanConfig.newName().orElse(TRACING_SPAN_HTTP_REQUEST);
if (spanName.indexOf('%') > -1) {
spanName = String.format(spanName, req.method().name(), req.path(), req.query());
spanName = String.format(spanName, req.method().text(), req.path(), req.query());
}
// tracing is enabled, so we replace the parent span with web server parent span
Span.Builder<?> spanBuilder = tracer.spanBuilder(spanName)
.kind(Span.Kind.SERVER)
.tag(Tag.COMPONENT.create("helidon-reactive-webserver"))
.tag(Tag.HTTP_METHOD.create(req.method().name()))
.tag(Tag.HTTP_METHOD.create(req.method().text()))
.tag(Tag.HTTP_URL.create(req.uri().toString()))
.tag(Tag.HTTP_VERSION.create(req.version().value()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader;

import io.helidon.common.HelidonServiceLoader;
import io.helidon.common.context.Contexts;
import io.helidon.tracing.HeaderConsumer;
import io.helidon.tracing.HeaderProvider;
Expand All @@ -36,7 +33,6 @@
import io.helidon.tracing.config.SpanTracingConfig;
import io.helidon.tracing.config.TracingConfigUtil;
import io.helidon.tracing.jersey.client.internal.TracingContext;
import io.helidon.tracing.spi.TracerProvider;

import jakarta.annotation.Priority;
import jakarta.ws.rs.Priorities;
Expand Down Expand Up @@ -138,22 +134,12 @@ public class ClientTracingFilter implements ClientRequestFilter, ClientResponseF
private static final int HTTP_STATUS_ERROR_THRESHOLD = 400;
private static final int HTTP_STATUS_SERVER_ERROR_THRESHOLD = 500;

private final Optional<TracerProvider> tracerProvider;

/**
* Default constructor so this filter can be registered with Jersey
* as a class.
* Required by integrated platform.
*/
public ClientTracingFilter() {
Iterator<TracerProvider> iterator = HelidonServiceLoader.create(ServiceLoader.load(TracerProvider.class))
.iterator();

if (iterator.hasNext()) {
tracerProvider = Optional.of(iterator.next());
} else {
tracerProvider = Optional.empty();
}
}

@Override
Expand Down
Loading