Hi all,
I hope someone can point me in the right direction here. I am using Spring Boot 3 in combination with Spring Modulith in my application. I get APM data in Kibana, so the configuration is fine. But, when I use an async event to communicate with the next module, APM does not collect data in the other modules.
Module 1 sending code (simplified):
@Service
public class Modul1Service {
private ApplicationEventPublisher events;
@Scheduled(fixedRate = 5000)
@Transactional
public void poll() {
events.publishEvent(new JobCreatedEvent());
}
}
Module 2 receiving code (simplified):
@Service
public class Modul2Service {
@CaptureSpan
@ApplicationModuleListener
void on(JobCreatedEvent event) {
//process
}
}
When enabling debug logs for the agent, I find the following log repeatedly:
Not creating span for Modul2Service#on because there is no currently active span.
As this is related to async processing, I checked your docs about asynchronous frameworks. As you support ExecutorService
I tried to force Spring to use this next:
@Bean
@Primary
ExecutorService asyncExecutor() {
return Executors.newVirtualThreadPerTaskExecutor();
}
/**
* required to use the custom async executor with virtual threads
*
* @return
*/
@Bean
ApplicationEventMulticaster applicationEventMulticaster() {
SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
eventMulticaster.setTaskExecutor(asyncExecutor());
return eventMulticaster;
}
Still, APM does not collect spans for the other modules. Any ideas how I can fix this?
Kibana version: 8.13.3
Elasticsearch version: 8.13
APM Server version: 8.13.3
APM Agent language and version: Java 1.49