Skip to content

Commit

Permalink
Polish "Fix observation scope handlings in grpc server instrumentation"
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye committed Jun 16, 2023
1 parent a1ca938 commit cba555c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Imports -->
<module name="IllegalImportCheck" >
<property name="id" value="GeneralIllegalImportCheck"/>
<property name="illegalPkgs" value="com.google.common.(?![cache|concurrent]).*,org.apache.commons.text.*,org.jetbrains.*,jdk.internal.jline.internal.*,reactor.util.annotation.*,org.checkerframework.checker.*,javax.ws.*"/>
<property name="illegalPkgs" value="com.google.common.(?!cache|util.concurrent).*,org.apache.commons.text.*,org.jetbrains.*,jdk.internal.jline.internal.*,reactor.util.annotation.*,org.checkerframework.checker.*,javax.ws.*"/>
<property name="illegalClasses" value="org\.assertj\.core\.api\.Java6Assertions\..*,javax.annotation.Nullable"/>
<property name="regexp" value="true"/>
</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -96,12 +93,11 @@ void simulate_trace_in_async_requests() {

// Send requests asynchronously with request-id in metadata.
// The request-id is stored in threadlocal in server when scope is opened.
// The main logic retrieves the request-id from threadlocal and include it as
// The main logic retrieves the request-id from threadlocal and includes it as
// part of the response message.
// This simulates a tracer with span.
SimpleServiceFutureStub stub = SimpleServiceGrpc.newFutureStub(this.channel);
Map<ListenableFuture<SimpleResponse>, String> requestIds = new HashMap<>();
List<ListenableFuture<SimpleResponse>> futures = new ArrayList<>();
int max = 40;
for (int i = 0; i < max; i++) {
String message = "Hello-" + i;
Expand All @@ -115,8 +111,8 @@ void simulate_trace_in_async_requests() {
.unaryRpc(request);

requestIds.put(future, requestId);
futures.add(future);
}
Set<ListenableFuture<SimpleResponse>> futures = requestIds.keySet();
await().until(() -> futures.stream().allMatch(Future::isDone));
assertThat(futures).allSatisfy((future) -> {
// Make sure the request-id in the response message matches with the one sent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void onFailure(Throwable t) {

}
}, Executors.newCachedThreadPool());
futures.add(stub.unaryRpc(request));
futures.add(future);
}

await().until(() -> futures.stream().allMatch(Future::isDone));
Expand Down

0 comments on commit cba555c

Please sign in to comment.