grpc-spring
grpc-spring copied to clipboard
Importing GrpcClientMetricAutoConfiguration disables some actuator metrics including hikari-cp, lettuce, jvm, ...
The bug
When I use grpcClient in my server, I cannot see some metrics like jvm, hikari-cp, lettuce and so on from actuator/metrics
endpoint.
But if I comment out the GrpcClientMetricAutoConfiguration importing line, I can see the metrics.
Stacktrace and logs x
Steps to Reproduce
kotlin code to reproduce:
@SpringBootApplication
class SpringBootApplication
fun main(args: Array<String>) {
runApplication<SpringBootApplication>(*args)
}
@Configuration
@ImportAutoConfiguration(
value = [
net.devh.boot.grpc.client.autoconfigure.GrpcClientAutoConfiguration::class,
net.devh.boot.grpc.client.autoconfigure.GrpcClientMetricAutoConfiguration::class, // if you comment out this line, you can see jvm metrics.
net.devh.boot.grpc.client.autoconfigure.GrpcClientHealthAutoConfiguration::class,
net.devh.boot.grpc.client.autoconfigure.GrpcClientSecurityAutoConfiguration::class,
net.devh.boot.grpc.client.autoconfigure.GrpcClientTraceAutoConfiguration::class,
net.devh.boot.grpc.client.autoconfigure.GrpcDiscoveryClientAutoConfiguration::class,
]
)
class GrpcConfig
@Component
class A(
@GrpcClient("test")
private val stub: testStub, // you should change this line to provide a valid stub
)
dependencies in build.gradle.kts:
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("net.devh:grpc-client-spring-boot-starter:2.14.0.RELEASE")
application.properties:
management.endpoints.web.exposure.include=*
When you run the server and access localhost:8080/actuator/metrics, you cannot see jvm.* metrics. But if you comment out the GrpcClientMetricAutoConfiguration importing line, you can see jvm.* metrics.
The application's environment
- Spring boot version: 3.0.2
- grpc-client-spring-boot-starter version: net.devh:grpc-client-spring-boot-starter:2.14.0.RELEASE
- java: 17 64bit osx
This might be an input ordering issue. Try adding @AutoConfigureAfter or Import Springs new Metrics autoconfiguration.
Fix:https://github.com/yidongnan/grpc-spring-boot-starter/pull/907
If the constructor injection is causing issues until the update. you can use the following approach:
@Component
class A {
@GrpcClient("test")
private lateinit var stub: TestStub
}
@Component
class A {
private var stub: TestStub
@GrpcClient("test")
fun setStub(stub: TestStub) {
this.stub = stub
}
}
Any update on this issue? As we would prefer to not use the above workaround.
Hey guys, Are there any updates on this? We've just run into the same problem on our project