Skip to content

Propagate trace context into envelopes #45

@nficano

Description

@nficano

TraceContext documents automatic task-local propagation at Sources/ARCP/Trace/TraceContext.swift:4, and the observability guide says envelopes built inside Tracing.withTrace inherit the trace automatically at docs/guides/observability.md:68. Envelope.init defaults traceId, spanId, and parentSpanId to nil at Sources/ARCP/Envelope/Envelope.swift:28 and never reads Tracing.current. JobManager stores the inbound trace id on JobRecord at Sources/ARCP/Runtime/JobManager.swift:188, but lifecycle and handler-emitted envelopes are built without trace fields, so runtime responses, logs, metrics, progress, and result chunks drop the trace.

Fix prompt: Wire Tracing.current into envelope construction or into the client and runtime send paths so default trace fields are populated when callers do not pass explicit values. Preserve inbound trace context from tool.invoke across job.accepted, job.started, handler context emissions, and terminal job envelopes. Add tests for Tracing.withTrace around ARCPClient.invoke and for runtime propagation from an inbound traced invocation through progress and terminal events.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity:mediumMedium severity issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions