Skip to content

feat(telemetry): one session id and one trace per turn (RPT-057) - #105

Draft
Nivesh353 wants to merge 1 commit into
open-gitagent:mainfrom
Nivesh353:fix/multiple-traces
Draft

feat(telemetry): one session id and one trace per turn (RPT-057)#105
Nivesh353 wants to merge 1 commit into
open-gitagent:mainfrom
Nivesh353:fix/multiple-traces

Conversation

@Nivesh353

Copy link
Copy Markdown
Collaborator

What — Every model request now carries X-Session-Id, and every request within a turn shares a traceparent.

Why — RPT-057: one gitagent run produced several unrelated traces in Studio with no way to correlate them or total consumption.

How — loadAgent() takes an optional session id (CLI --session-id, SDK sessionId) and puts it on the model's headers, cloned so the shared pi-ai registry object isn't mutated. startTurnTrace() sets a fresh traceparent before each turn.

Verified — Against dev: two traces sharing one session id, then a single trace of 12 spans once the server-side change landed

One user turn costs several requests to the model gateway — one returns a
tool call, the next the answer. The gateway traced each separately, so a
single "hi" showed up as two unrelated traces with no way to total them.

Send X-Session-Id (this run's id, overridable via --session-id or the SDK's
sessionId) on every request, and a per-turn traceparent so the gateway can
stitch a turn's requests into one trace. Both no-op safely: the header is
set on a cloned model, and traceparent yields to the undici instrumentation
when OTel is initialised.
@Nivesh353
Nivesh353 marked this pull request as draft August 14, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant