Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing GrpcClientMetricAutoConfiguration disables some actuator metrics including hikari-cp, lettuce, jvm, ... #859

Open
ml-taehoon-choi opened this issue Mar 9, 2023 · 4 comments
Labels
bug Something does not work as expected feedback required Information are missing or feedback for suggestions is requested incompatibility Incompatibilities between components or versions

Comments

@ml-taehoon-choi
Copy link

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
@ml-taehoon-choi ml-taehoon-choi added the bug Something does not work as expected label Mar 9, 2023
@ST-DDT
Copy link
Collaborator

ST-DDT commented Mar 9, 2023

This might be an input ordering issue. Try adding @AutoConfigureAfter or Import Springs new Metrics autoconfiguration.

@ST-DDT ST-DDT added feedback required Information are missing or feedback for suggestions is requested incompatibility Incompatibilities between components or versions labels Mar 9, 2023
@SOOHYUN-LIM
Copy link

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
    }
}

@k3vonk
Copy link

k3vonk commented Mar 12, 2024

Any update on this issue? As we would prefer to not use the above workaround.

@aron9609
Copy link

Hey guys,
Are there any updates on this?
We've just run into the same problem on our project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as expected feedback required Information are missing or feedback for suggestions is requested incompatibility Incompatibilities between components or versions
Projects
None yet
Development

No branches or pull requests

5 participants