Improve support for virtual thread detection by PerfectSlayer · Pull Request #9852 · DataDog/dd-trace-java
What Does This Do
This PR improves the environment component to be able to check for virtual threads support.
EDIT: Support was already added in #9537 then this PR only brings few additional elements compared to the original ThreadUtils:
- A syntactic sugar helper for
threadId()with current thread - Expose the
newVirtualThreadPerTaskExecutor()ExecutorServicesto allow its usage from core - Use
JavaVirtualMachine.isJavaVersionAtLeast()instead ofJavaVersion.getRuntimeVersion().isAtLeast()to avoid parsing version number multiple times - Change name from
ThreadUtilsto theThreadSupportas there are already twoThreadUtilsclasses (datadog.trace.ThreadUtilsanddatadog.trace.agent.test.utils.ThreadUtils)
Motivation
With the adoption of modern Java versions, we will need to check for virtual threads to avoid expensive per-thread work or memory allocation (like ThreadLocals).
Additional Notes
Contributor Checklist
- Format the title according the contribution guidelines
- Assign the
type:and (comp:orinst:) labels in addition to any useful labels - Don't use
close,fixor any linking keywords when referencing an issue.
Usesolvesinstead, and assign the PR milestone to the issue - Update the CODEOWNERS file on source file addition, move, or deletion
- Update the public documentation in case of new configuration flag or behavior
Jira ticket: [PROJ-IDENT]