Skip to content

Commit e8c1ec1

Browse files
committed
Fix gRPC interceptors lookup in Micrometer binders
1 parent 30d7be6 commit e8c1ec1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/GrpcBinderProcessor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import java.util.function.BooleanSupplier;
44

55
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
6+
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
67
import io.quarkus.deployment.annotations.BuildProducer;
78
import io.quarkus.deployment.annotations.BuildStep;
89
import io.quarkus.deployment.builditem.AdditionalIndexedClassesBuildItem;
9-
import io.quarkus.micrometer.runtime.MicrometerRecorder;
1010
import io.quarkus.micrometer.runtime.config.MicrometerConfig;
1111

1212
/**
@@ -22,27 +22,27 @@ public class GrpcBinderProcessor {
2222
static final String CLIENT_INTERCEPTOR = "io.grpc.ClientInterceptor";
2323
static final String SERVER_INTERCEPTOR = "io.grpc.ServerInterceptor";
2424

25-
static final Class<?> CLIENT_INTERCEPTOR_CLASS = MicrometerRecorder.getClassForName(CLIENT_INTERCEPTOR);
26-
static final Class<?> SERVER_INTERCEPTOR_CLASS = MicrometerRecorder.getClassForName(SERVER_INTERCEPTOR);
27-
2825
static class GrpcClientSupportEnabled implements BooleanSupplier {
2926
MicrometerConfig mConfig;
3027

3128
public boolean getAsBoolean() {
32-
return CLIENT_INTERCEPTOR_CLASS != null && mConfig.checkBinderEnabledWithDefault(mConfig.binder.grpcClient);
29+
return QuarkusClassLoader.isClassPresentAtRuntime(CLIENT_INTERCEPTOR)
30+
&& mConfig.checkBinderEnabledWithDefault(mConfig.binder.grpcClient);
3331
}
3432
}
3533

3634
static class GrpcServerSupportEnabled implements BooleanSupplier {
3735
MicrometerConfig mConfig;
3836

3937
public boolean getAsBoolean() {
40-
return SERVER_INTERCEPTOR_CLASS != null && mConfig.checkBinderEnabledWithDefault(mConfig.binder.grpcServer);
38+
return QuarkusClassLoader.isClassPresentAtRuntime(SERVER_INTERCEPTOR)
39+
&& mConfig.checkBinderEnabledWithDefault(mConfig.binder.grpcServer);
4140
}
4241
}
4342

4443
@BuildStep(onlyIf = GrpcClientSupportEnabled.class)
45-
AdditionalBeanBuildItem addGrpcClientMetricInterceptor() {
44+
AdditionalBeanBuildItem addGrpcClientMetricInterceptor(BuildProducer<AdditionalIndexedClassesBuildItem> producer) {
45+
producer.produce(new AdditionalIndexedClassesBuildItem(CLIENT_GRPC_METRICS_INTERCEPTOR));
4646
return AdditionalBeanBuildItem.unremovableOf(CLIENT_GRPC_METRICS_INTERCEPTOR);
4747
}
4848

0 commit comments

Comments
 (0)