newrelic / newrelic-java-agent

The New Relic Java agent
Apache License 2.0
202 stars 143 forks source link

Add vertx-core-4.5.3 AsyncHandlerWrapper instrumentation #1774

Closed tugcesahin closed 4 months ago

tugcesahin commented 8 months ago

Is your feature request related to a problem? Please describe.

After upgrading Quarkus version from 3.6.8 to 3.8.1 and newrelic-agent and newrelic-api versions from 8.6.0 to 8.9.1, ~I saw that newrelic-java-agent does not support vertx-core-4.5.3 AsyncHandlerWrapper instrumentation and that causes~ and started seeing NPE on smallrye health checks. Here the logs: Message: Uncaught exception received by Vert.x stack trace:

java.lang.NullPointerException: Cannot invoke "io.vertx.core.Handler.handle(Object)" because "this.original" is null
    at com.nr.vertx.instrumentation.AsyncHandlerWrapper.handle(AsyncHandlerWrapper.java:32)
    at com.nr.vertx.instrumentation.AsyncHandlerWrapper.handle(AsyncHandlerWrapper.java:14)
    at io.vertx.core.impl.future.FutureImpl$4.onSuccess(FutureImpl.java:176)
    at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:60)
    at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:1583)

Feature Description

vertx-core-4.5.3 AsyncHandlerWrapper instrumentation should be added.

Describe Alternatives

A clear and concise description of any alternative solutions or features you've considered. Are there examples you could link us to?

Additional context

Add any other context here.

Priority

Please help us better understand this feature request by choosing a priority from the following options: Must Have

workato-integration[bot] commented 8 months ago

https://new-relic.atlassian.net/browse/NR-234403

meiao commented 8 months ago

The agent does support that version of Vertx. That AsyncHandlerWrapper is a New Relic class.

Now there are 2 possible reasons why a NPE is happening there:

  1. the original handler that this wrapper receives is null;
  2. the wrapper is being called twice.

Both these cases were not expected when this was created. So we will have to investigate what is the proper solution.

InfocertTeamIdentity commented 6 months ago

is there any update for this issue?

aestebangarcianavas commented 6 months ago

Hey! We are blocked with the Quarkus updates because of this issue and are facing now security vulnerabilities because of this, like https://security.snyk.io/vuln/SNYK-JAVA-IOQUARKUS-6596815. The last try I did is to update to Quarkus 3.9.3 and we are still getting this NPE

java.lang.NullPointerException: Cannot invoke "io.vertx.core.Handler.handle(Object)" because "this.original" is null
    at com.nr.vertx.instrumentation.AsyncHandlerWrapper.handle(AsyncHandlerWrapper.java:32)
    at com.nr.vertx.instrumentation.AsyncHandlerWrapper.handle(AsyncHandlerWrapper.java:14)
    at io.vertx.core.impl.future.FutureImpl$4.onSuccess(FutureImpl.java:176)
    at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:60)
    at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:840)

Is there any workaround? It's being too long waiting for this fix... Thanks!

alrasch commented 6 months ago

I have the same problem. My only workaround is to downgrade the NewRelic agent to 8.8.x to prevent this error spam.

The issue started in 8.9.0 and persists in 8.11.0 (current latest).

Downgrading the NR agent version allows you to bump Quarkus versions safely, though.

alrasch commented 5 months ago

@kanderson250 - Sorry to bump, but have you been able to find any leads on this issue?

As I mentioned earlier, my current workaround is to keep the agent downgraded, which of course is a smell in the long run, and produces warnings in the NewRelic UI.

kanderson250 commented 5 months ago

@alrasch Understood. We just pulled this into development and are hoping to get a fix out soon.

By any chance, would you be able to provide a minimal code example that produces the error for you?

kanderson250 commented 5 months ago

Pinging some other people in this thread @tugcesahin @aestebangarcianavas - are you able to provide a simple repro code example? Or reproduction steps?

kanderson250 commented 4 months ago

Hey all, we updated the vertx-4.5.1 instrumentation. If you're willing to try it in your environment, see the snapshot jar published here: https://github.com/newrelic/newrelic-java-agent/actions/runs/9389158384

The jar is available for download under "Artifacts" as custom-newrelic-jar.

ana-sqills commented 4 months ago

Hi! Many thanks! I tested with the jar and it is working fine. Is the version already available in the maven central repo?

ana-sqills commented 4 months ago

Hi! I checked today the maven central project https://mvnrepository.com/artifact/com.newrelic.agent.java/newrelic-agent and the release is not published yet. Do you have an estimation, how long we will need to wait for it? Thanks in advance :)

meiao commented 4 months ago

This will be in version 8.13.0, which should be released in mid to late July.