Opentelemetry_ambient_context_eio uses Eio's fiber-local storage. Contrary to the documented behavior, which says
Each fiber maintains a map of additional variables associated with it, which can be used to store fiber-related state or context. This map is propagated to any forked fibers.
Fiber-local storage is not shared with forked fibers within a spawned domain. This is discussed in This is discussed in ocaml-multicore/eio#807 .
This is not a bug with the ambient context module, per se, merely a limitation worth noting, inherited from Eio.
However, as reported by @ajbt200128, it does produce arguably buggy (at minimum, surprising) behavior when tracing, since any time a domain is spawned, computations that otherwise appear to be in a child fiber will end up with new span ID.
AFAIK, the only way for us to address without upstream changes to Eio would be reimplement the ambient context to rely on some sort of global storage backend.
I'm creating this issue to track the known limitation and as a place for further discussion.