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

Micrometer Tracing doesn't work with @GrpcClient injection in constructors #1138

Open
artsidorenko opened this issue Sep 2, 2024 · 0 comments
Labels
bug Something does not work as expected

Comments

@artsidorenko
Copy link

The context

I was trying to setup observability for application, that use both GrpcServer and GrpcClient.

The bug

It seems that configuration order of micrometer tracing breaks when I add @GrpcClient like ctor parameter for my service, for example:

@Service
class MyService(
    @GrpcClient("my-client")
    private val myClient: OtherServiceGrpcKt.OtherServiceCoroutineStub
) {...}
  1. The ObservationRegistry, needed to configure tracing interceptors is noOp, so traces don't work.

  2. Everything works fine if I add @GrpcClient as lateinit property to my service and do not use ctor injection.

  3. Also works if I add Configuration with @GrpcClientBean and inject client beans without @GrpcClient. (btw, it seems that @dependsOn on config with client beans is necessary, otherwise spring fails to find these beans)

  4. And also (that is strange) works if I exclude GrpcClientMicrometerAutoConfiguration:

spring:
  autoconfigure:
    exclude: net.devh.boot.grpc.client.autoconfigure.GrpcClientMicrometerTraceAutoConfiguration

and copy-paste source code of this class to my own code)

Stacktrace and logs
There are tons of WARNs like:
trationDelegate$BeanPostProcessorChecker : Bean 'net.devh.boot.grpc.client.autoconfigure.GrpcClientAutoConfiguration' of type [net.devh.boot.grpc.client.autoconfigure.GrpcClientAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [grpcClientBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.

These WARNs are absent in 2) and 3).

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create class via the @GrpcClient injected in ctor.
  2. Expose some endpoint like hello and try to log traceIds there
  3. (*) Try to add logging via ObservationHandler and see that your handler is not registered (and ObservationRegistry is noop as well).

The application's environment

Which versions do you use?

  • Spring (boot): 3.3.0
  • grpc-java: 1.64.0
  • grpc-kotlin-stub: 1.4.1
  • grpc-spring-boot-starter: 3.1.0.RELEASE

Additional context

I see that @GrpcClient constructor injection is experimental (as said in javadoc). Hope this issue helps you somehow

@artsidorenko artsidorenko added the bug Something does not work as expected label Sep 2, 2024
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
Projects
None yet
Development

No branches or pull requests

1 participant