Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Spring @EventListener @Trace not working


I have a simple java console application where in the main method, an event is published to the ApplicationContext. In another class, I have a method annotated with @EventListener and @Trace(dispatcher = true)

No transaction is recorded. I also tried adding async=true to the @Trace to no effect. Is @EventListener not supported?

java agent: 4.12.1


Hey @rjenkins. The agent doesn’t have built-in instrumentation for the EventListener annotation. However, I would expect the @Trace(dispatcher=true) to start a transaction. One thing to keep in mind is that if there is a thread context switch then you’ll need to pass a token and link it with the Token API.

Also, since this is a console app, you might want to check to see if the transaction is showing up under non-web in the UI. If it’s not there and you feel you’ve covered the bases above, can you post the sources or a link to sources that I could take a look at and replicate?


If I’m starting a new transaction with @Trace(dispatcher=true) do I still need to use tokens? I thought tokens were just to link methods run in new threads to a ‘parent thread’ transaction.


That’s correct. If you’re just starting a new transaction and not trying to link any async work that originates from that point, then you won’t need to link it.

However, if there is an existing Transaction, then the dispatcher=true would get ignored and that span would be associated with whatever existing Transaction it is on. Were you able to confirm if there is an existing non-web Transaction that is picking up this work ? It’s easy to miss, so just double checking. On the Transactions page show either All Transactions or non-web and see if it’s getting picked up there. If you want, shoot me a link to the app and I can take a look to see what all might be going on. I can see some metrics that may be useful for troubleshooting.


I ended up finding that transactions aren’t what we want for the sort of tracking we want to do anyway (too many transactions and we need real numbers in insights, not samples, so we have to use custom metrics instead apparently).

Thanks anyway for your help and the offer of looking into it.