Since moving to spring boot 3.0 tracing has stopped working with scheduled jobs @Scheduled(fixedDelay = 69, timeUnit = TimeUnit.SECONDS)
According to migration docs we should be wrapping the executor service with ContextScheduledExecutorService.wrap()
https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide#async-instrumentation
And according to spring docs we should be able to do it like this
@Configuration
@EnableScheduling
public class AppConfig implements SchedulingConfigurer {
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskExecutor());
}
@Bean(destroyMethod="shutdown")
public Executor taskExecutor() {
return ContextScheduledExecutorService.wrap(Executors.newScheduledThreadPool(100));
}
}
The correct scheduler is being used as I can see custom thread name when setting one, but log tracing does not show up (traceId, spanId). Otherwise tracing works as I can see it when calling api methods in same application.
3.2.0-M1
I've confirmed the fix on3.2.0-M3
. The RC is scheduled for 19/10. See the issue page – Mildredmildrid