Skip to content
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 @@ -185,6 +185,6 @@ public static JaegerRemoteSamplerBuilder builder() {
public void close() {
pollFuture.cancel(true);
pollExecutor.shutdownNow();
grpcSender.shutdown();
grpcSender.shutdown().join(10, TimeUnit.SECONDS);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is consistent with SpanExporter, MetricExporter, LogRecordExporter close implementation.

JaegerREmoteSamplerTest would be prone to the same test flake as JaegerRemoteSamplerGrpcNettyTest if it weren't for a bug in which the server called grpcErrors.peek() instead of poll(). This causes JaegerRemoteSamplerTest to avoid test flakes by ignoring the error queue and just returning the same error over and over.

I fixed the peek / poll but, but need to make sure shutdown is thorough to isolate test cases, else JaegerRemoteSamplerTest will start being flaky.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ public void getSamplingStrategy(
io.opentelemetry.sdk.extension.trace.jaeger.proto.api_v2
.Sampling.SamplingStrategyResponse>
responseObserver) {
ArmeriaStatusException grpcError = grpcErrors.peek();
ArmeriaStatusException grpcError = grpcErrors.poll();
if (grpcError != null) {
responseObserver.onError(grpcError);
return;
}
Sampling.SamplingStrategyResponse response = responses.poll();
// use default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,21 @@ public void before() {
private ManagedChannel managedChannel() {
ManagedChannel channel =
ManagedChannelBuilder.forTarget(server.httpUri().getAuthority()).usePlaintext().build();
cleanup.addCloseable(channel::shutdownNow);
cleanup.addCloseable(
() -> {
// Graceful shutdown ensures the server has processed all in-flight requests before
// the next test starts, preventing stale requests from consuming errors added to the
// queue by a subsequent test.
channel.shutdown();
try {
if (!channel.awaitTermination(10, TimeUnit.SECONDS)) {
channel.shutdownNow();
}
} catch (InterruptedException e) {
channel.shutdownNow();
Thread.currentThread().interrupt();
}
});
return channel;
}

Expand Down
Loading