Trace-linked continuous profiling promises the holy grail of debugging: click a slow distributed trace span and instantly inspect the flame graph of CPU time consumed by that exact request. On standard platform threads, this works reliably. On JVM virtual threads, it silently lies to you.
Continuous profilers like Pyroscope link samples by having the OpenTelemetry span processor write the active span ID into a native OS thread-local storage slot. When the sampling timer fires every 10 milliseconds, the native sampler reads this slot to attribute CPU samples.
The fatal flaw emerges when virtual threads enter the equation. Because virtual threads unmount and switch carrier OS threads cooperatively during blocking operations, a carrier thread can resume executing a different virtual thread while still holding the stale native span tag from the previous request. Your profiler never throws an error, but it quietly assigns expensive CPU work to the wrong user request.
Understanding how native runtime constructs interact with user-space schedulers is crucial before rolling out virtual threads in high-throughput observability stacks.








