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

[Spring Scheduling] Support Virtual Threads #13370

Merged
merged 1 commit into from
Feb 22, 2025

Conversation

jakobjoachim
Copy link
Contributor

Spring uses a different TaskScheduler when using virtual threads. See the org.springframework.boot.autoconfigure.task.TaskSchedulerConfiguration below:

static class TaskSchedulerConfiguration {
        @Bean(name = "taskScheduler")
        @ConditionalOnThreading(Threading.VIRTUAL)
        SimpleAsyncTaskScheduler taskSchedulerVirtualThreads(SimpleAsyncTaskSchedulerBuilder builder) {
	        return builder.build();
        }
        
        @Bean
        @SuppressWarnings({ "deprecation", "removal" })
        @ConditionalOnThreading(Threading.PLATFORM)
        ThreadPoolTaskScheduler taskScheduler(org.springframework.boot.task.TaskSchedulerBuilder taskSchedulerBuilder,
		        ObjectProvider<ThreadPoolTaskSchedulerBuilder> threadPoolTaskSchedulerBuilderProvider) {
	        ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder = threadPoolTaskSchedulerBuilderProvider
		        .getIfUnique();
	        if (threadPoolTaskSchedulerBuilder != null) {
		        return threadPoolTaskSchedulerBuilder.build();
	        }
	        return taskSchedulerBuilder.build();
        }
}

This Change adds the SimpleAsyncTaskScheduler to the instrumented classes

@jakobjoachim jakobjoachim requested a review from a team as a code owner February 21, 2025 11:42
Copy link

linux-foundation-easycla bot commented Feb 21, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: jakobjoachim / name: Jakob Joachim (3dd8a4b)

@jakobjoachim jakobjoachim force-pushed the main branch 2 times, most recently from aad942e to d520644 Compare February 21, 2025 11:49
@trask trask merged commit 08a0de3 into open-telemetry:main Feb 22, 2025
61 checks passed
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

Successfully merging this pull request may close these issues.

3 participants