pub fn remote_span_context(
trace_hex: &str,
span_hex: &str,
) -> Option<SpanContext>otel only.Expand description
Build a remote SpanContext from hex-encoded trace + span ids, for
re-parenting spans under a span that is no longer live in the
current task.
The daemon-hosted worker drives a turn across multiple tasks
(execute → suspend at the tool boundary → resume), so its root
invoke_agent span cannot stay live for the whole turn. The worker
persists the root span’s (trace_id, span_id) and rebuilds a remote
parent context from them via this helper so resumed chat calls and
child-task execute_tool calls nest under the turn root. Returns
None for malformed / zero ids (treated as “no parent”).
Legacy entry point — assumes the remote parent was sampled. It
always marks the reconstructed context SAMPLED, which forces a
ParentBased sampler to record every re-parented child even when the
root span was sampled out. Prefer remote_span_context_with_sampling
and pass the root span’s real sampled bit so ratio sampling configured
for the root is honoured by its children.