fix(#2779): respect inbound TRACEPARENT in trace chain - #2833
fix(#2779): respect inbound TRACEPARENT in trace chain#2833fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
When fullsend runs inside an instrumented pipeline that already exports TRACEPARENT, the runner now adopts the inbound trace-id (continuing the distributed trace chain) instead of generating a fresh one. The W3C trace-flags sampled bit is preserved so upstream sampling decisions are honored. The security trace-id is derived from the inbound trace-id via UUID reformatting. Additionally, childScriptEnv now filters any pre-existing TRACEPARENT from os.Environ() before appending, ensuring exactly one entry is present regardless of the parent environment. Shell interpolation guards (injectTraceID, buildScanContextCommand) use the new IsShellSafeTraceID validator that accepts any dashed-hex UUID format, not just UUID v4, since adopted trace-ids may have arbitrary version/variant bits. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Site previewPreview: https://01b387ed-site.fullsend-ai.workers.dev Commit: |
|
Didn't mean to get this autocoded. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
🤖 Finished Retro · ✅ Success · Started 7:57 AM UTC · Completed 8:02 AM UTC |
Retro: PR #2833 — Unwanted autocoding from
|
When a parent process exports TRACEPARENT (nested or instrumented invocation), fullsend now continues that trace instead of starting its own: the inbound trace-id becomes the unified security/W3C trace id, the inbound span-id is recorded as the root span's remote parent, and the inbound trace-flags are preserved through child-script TRACEPARENT, the recorder, and run-summary.json (previously hardcoded to sampled). childScriptEnv now filters any TRACEPARENT already present — inherited from the process environment or set in runner_env — so exactly one entry, fullsend's own, is seen by child scripts; env lookups resolve the first match, so a stale value used to shadow it. TRACESTATE passes through untouched. The shell-safety call sites switch to IsShellSafeTraceID since adopted ids are not UUID v4. The adoption logic lives in resolveTraceIdentity, a pure helper, so the behavior is unit-testable outside runAgent. Supersedes and ports fullsend-ai#2833 (closed unmerged for process reasons), adding the remote-parent record, summary flag fidelity, and W3C forward-compatible version parsing that the original missed. Signed-off-by: Dharit Shah <dhshah@redhat.com>
When a parent process exports TRACEPARENT (nested or instrumented invocation), fullsend now continues that trace instead of starting its own: the inbound trace-id becomes the unified security/W3C trace id, the inbound span-id is recorded as the root span's remote parent, and the inbound trace-flags are preserved through child-script TRACEPARENT, the recorder, and run-summary.json (previously hardcoded to sampled). childScriptEnv now filters any TRACEPARENT already present — inherited from the process environment or set in runner_env — so exactly one entry, fullsend's own, is seen by child scripts; env lookups resolve the first match, so a stale value used to shadow it. TRACESTATE passes through untouched. The shell-safety call sites switch to IsShellSafeTraceID since adopted ids are not UUID v4. The adoption logic lives in resolveTraceIdentity, a pure helper, so the behavior is unit-testable outside runAgent. Supersedes and ports fullsend-ai#2833 (closed unmerged for process reasons), adding the remote-parent record, summary flag fidelity, and W3C forward-compatible version parsing that the original missed. Signed-off-by: Dharit Shah <dhshah@redhat.com>
When fullsend runs inside an instrumented pipeline that already exports TRACEPARENT, the runner now adopts the inbound trace-id (continuing the distributed trace chain) instead of generating a fresh one. The W3C trace-flags sampled bit is preserved so upstream sampling decisions are honored. The security trace-id is derived from the inbound trace-id via UUID reformatting.
Additionally, childScriptEnv now filters any pre-existing TRACEPARENT from os.Environ() before appending, ensuring exactly one entry is present regardless of the parent environment.
Shell interpolation guards (injectTraceID, buildScanContextCommand) use the new IsShellSafeTraceID validator that accepts any dashed-hex UUID format, not just UUID v4, since adopted trace-ids may have arbitrary version/variant bits.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Closes #2779
Post-script verification
agent/2779-respect-inbound-traceparent)eb4cd140210bf3a65693a3c748889102b0ef5f6a..HEAD)