You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Runtime.default.unsafe.run() permanently wipes the calling thread's
Context.current() because TracingSupervisor.onSuspend() unconditionally
calls Context.root().makeCurrent() when the fiber completes.
This affects any code that calls unsafe.run from a thread with existing
OTel context — e.g. Doobie transactor threads (which have context from
the agent's Executor wrapping), Java callbacks, or cats-effect bridges.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy file name to clipboardExpand all lines: instrumentation/zio/zio-2.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/zio/v2_0/ZioRuntimeInstrumentationTest.scala
Copy file name to clipboardExpand all lines: instrumentation/zio/zio-2.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/zio/v2_0/ZioTestFixtures.scala
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,36 @@ object ZioTestFixtures {
122
122
}
123
123
}
124
124
125
+
/**
126
+
* Demonstrates that Runtime.default.unsafe.run() destroys the calling thread's
127
+
* OTel context. The onSuspend handler calls Context.root().makeCurrent() when
128
+
* the fiber completes, which wipes any pre-existing context on the calling thread.
129
+
*
130
+
* Returns (traceIdBefore, traceIdAfter) so the test can assert they match.
0 commit comments