Skip to content

Commit

Permalink
Fix quarkusio#23011 - Do not list the micrometer gRPC interceptors as…
Browse files Browse the repository at this point in the history
… non-global interceptors
  • Loading branch information
cescoffier committed Jan 20, 2022
1 parent ad516dc commit ef6d5f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static io.quarkus.grpc.deployment.GrpcDotNames.CONFIGURE_STUB;
import static io.quarkus.grpc.deployment.GrpcDotNames.CREATE_CHANNEL_METHOD;
import static io.quarkus.grpc.deployment.GrpcDotNames.RETRIEVE_CHANNEL_METHOD;
import static io.quarkus.grpc.deployment.GrpcInterceptors.MICROMETER_INTERCEPTORS;
import static io.quarkus.grpc.deployment.ResourceRegistrationUtils.registerResourcesForProperties;

import java.util.ArrayList;
Expand Down Expand Up @@ -359,6 +360,11 @@ SyntheticBeanBuildItem clientInterceptorStorage(GrpcClientRecorder recorder, Rec
// The rest, if anything stays, should be logged as problematic
Set<String> superfluousInterceptors = new HashSet<>(interceptors.nonGlobalInterceptors);

// Remove the metrics interceptors
for (String MICROMETER_INTERCEPTOR : MICROMETER_INTERCEPTORS) {
superfluousInterceptors.remove(MICROMETER_INTERCEPTOR);
}

List<AnnotationInstance> found = new ArrayList<>(index.getAnnotations(GrpcDotNames.REGISTER_CLIENT_INTERCEPTOR));
for (AnnotationInstance annotation : index.getAnnotations(GrpcDotNames.REGISTER_CLIENT_INTERCEPTOR_LIST)) {
for (AnnotationInstance nested : annotation.value().asNestedArray()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.jboss.jandex.ClassInfo;
Expand All @@ -13,6 +14,10 @@

final class GrpcInterceptors {

static final List<String> MICROMETER_INTERCEPTORS = List.of(
"io.micrometer.core.instrument.binder.grpc.MetricCollectingClientInterceptor",
"io.micrometer.core.instrument.binder.grpc.MetricCollectingServerInterceptor");

final Set<String> globalInterceptors;
final Set<String> nonGlobalInterceptors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static io.quarkus.grpc.deployment.GrpcDotNames.BLOCKING;
import static io.quarkus.grpc.deployment.GrpcDotNames.NON_BLOCKING;
import static io.quarkus.grpc.deployment.GrpcDotNames.TRANSACTIONAL;
import static io.quarkus.grpc.deployment.GrpcInterceptors.MICROMETER_INTERCEPTORS;
import static java.util.Arrays.asList;

import java.lang.reflect.Modifier;
Expand Down Expand Up @@ -385,6 +386,11 @@ void gatherGrpcInterceptors(BeanArchiveIndexBuildItem indexBuildItem,
// the rest, if anything stays, should be logged as problematic
Set<String> superfluousInterceptors = new HashSet<>(interceptors.nonGlobalInterceptors);

// Remove the metrics interceptors
for (String MICROMETER_INTERCEPTOR : MICROMETER_INTERCEPTORS) {
superfluousInterceptors.remove(MICROMETER_INTERCEPTOR);
}

List<AnnotationInstance> found = new ArrayList<>(index.getAnnotations(GrpcDotNames.REGISTER_INTERCEPTOR));
for (AnnotationInstance annotation : index.getAnnotations(GrpcDotNames.REGISTER_INTERCEPTORS)) {
for (AnnotationInstance nested : annotation.value().asNestedArray()) {
Expand Down

0 comments on commit ef6d5f2

Please sign in to comment.