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

Micronaut 2.0.0 doesn't work with metrics #62

Closed
ilopmar opened this issue Mar 12, 2020 · 1 comment
Closed

Micronaut 2.0.0 doesn't work with metrics #62

ilopmar opened this issue Mar 12, 2020 · 1 comment
Assignees

Comments

@ilopmar
Copy link
Contributor

ilopmar commented Mar 12, 2020

Micronaut 2.0 doesn't work with Metrics.

Steps to Reproduce

  • git clone https://github.com/micronaut-graal-tests/micronaut-management-graal
  • cd micronaut-management-graal
  • ./gradlew run

Expected Behaviour

The application should start.

Actual Behaviour

> Task :run FAILED
09:12:58.946 [main] DEBUG i.m.c.beans.DefaultBeanIntrospector - Found BeanIntrospection for type: class io.micronaut.health.HeartbeatDiscoveryClientCondition
09:12:59.005 [main] DEBUG i.m.c.beans.DefaultBeanIntrospector - Found BeanIntrospection for type: class io.micronaut.health.HeartbeatDiscoveryClientCondition
09:12:59.006 [ForkJoinPool.commonPool-worker-2] DEBUG io.micronaut.core.reflect.ClassUtils - Attempting to dynamically load class io.methvin.watchservice.MacOSXListeningWatchService
09:12:59.008 [ForkJoinPool.commonPool-worker-2] DEBUG io.micronaut.core.reflect.ClassUtils - Class io.methvin.watchservice.MacOSXListeningWatchService is not present
09:12:59.009 [ForkJoinPool.commonPool-worker-2] DEBUG io.micronaut.core.reflect.ClassUtils - Attempting to dynamically load class io.methvin.watchservice.MacOSXListeningWatchService
09:12:59.009 [ForkJoinPool.commonPool-worker-2] DEBUG io.micronaut.core.reflect.ClassUtils - Class io.methvin.watchservice.MacOSXListeningWatchService is not present
09:12:59.082 [Thread-1] DEBUG i.m.c.beans.DefaultBeanIntrospector - Found BeanIntrospection for type: class io.micronaut.scheduling.io.watch.FileWatchCondition
09:12:59.235 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: io.micronaut.configuration.metrics.binder.executor.ExecutorServiceMetricsBinder$1 cannot be cast to io.netty.channel.EventLoopGroup
java.lang.ClassCastException: io.micronaut.configuration.metrics.binder.executor.ExecutorServiceMetricsBinder$1 cannot be cast to io.netty.channel.EventLoopGroup
	at io.micronaut.http.server.netty.NettyHttpServer.createWorkerEventLoopGroup(NettyHttpServer.java:480)
	at io.micronaut.http.server.netty.NettyHttpServer.start(NettyHttpServer.java:271)
	at io.micronaut.http.server.netty.NettyHttpServer.start(NettyHttpServer.java:96)
	at io.micronaut.runtime.Micronaut.lambda$start$2(Micronaut.java:70)
	at java.util.Optional.ifPresent(Optional.java:159)
	at io.micronaut.runtime.Micronaut.start(Micronaut.java:68)
	at io.micronaut.runtime.Micronaut.run(Micronaut.java:294)
	at io.micronaut.runtime.Micronaut.run(Micronaut.java:280)
	at example.micronaut.Application.main(Application.java:8)

FAILURE: Build failed with an exception.

Environment Information

  • Operating System: Linux Mint
  • Micronaut Version: 2.0.0.BUILD-SNAPSHOT
  • JDK Version: 1.8

Example Application

https://github.com/micronaut-graal-tests/micronaut-management-graal

@graemerocher graemerocher transferred this issue from micronaut-projects/micronaut-core Mar 16, 2020
@graemerocher graemerocher self-assigned this Mar 16, 2020
@mitchnull
Copy link

mitchnull commented May 31, 2022

This fix strips any previous instrumentations. I don't think that was intentional. As far as I can see here you should return the original bean (executorService) instead of the unwrapped netty bean (in ExecutionServiceMetricsBinder.onCreate):

        if (unwrapped.getClass().getName().startsWith("io.netty")) {
            return unwrapped; // this should be: return executionService;
        }

With the current code, if we try to instrument a netty EventLoopGroup then we run into 2 failure scenarios:

  1. the above code strips our own instrumentation if we implement InstrumentedExecutionService
  2. re-introduce the original bug if we do not implement InstrumentedExecutionService as the special (and rather ugly) hack for io.netty package match fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants