Skip to content

[DOCS] Document W3C trace context propagation to subprocesses and OTLP span ingestion #391

Description

@edenreich

Summary

inference-gateway/cli#909 (closes inference-gateway/cli#904) makes subprocess and remote-agent tracing cooperative and open-standard. The propagation contract is user-facing and undocumented.

Behavior to document (all gated on telemetry.enabled: true):

  • Env vars for subprocesses: the Bash tool (and therefore skill scripts) and headless subagents receive TRACEPARENT/TRACESTATE (W3C Trace Context, parented on the current execute_tool span) and BAGGAGE (W3C Baggage: infer.session.id, infer.tool.call.id). Nothing is set when telemetry is disabled.
  • Span reporting is standard OTLP, chosen automatically:
    • telemetry.otlp.endpoint configured: the endpoint and headers are passed through to the child env (OTEL_EXPORTER_OTLP_ENDPOINT/OTEL_EXPORTER_OTLP_HEADERS) so child spans stitch in the remote backend.
    • No endpoint (the default): the CLI runs an ephemeral localhost OTLP/HTTP receiver per session and points children at it; received spans are persisted into the local per-session trace store and appear in infer traces / /traces nested under the tool span.
  • Any OTel-instrumented tool works with zero custom code. Example with otel-cli inside a Bash tool call:
otel-cli exec --name "go test" -- go test ./...

The resulting span shows up as a child of execute_tool Bash in infer traces.

  • Subagents: infer agent honors an inherited TRACEPARENT, so a subagent session nests under the caller's execute_tool Agent span - one cross-process trace:
session (standard, success)            152ms
|-- execute_tool Agent                  89ms
|   `-- session (readonly, success)     52ms
|       `-- chat openai/gpt-4o          13ms
  • Remote A2A agents: outbound A2A requests carry traceparent/tracestate/baggage HTTP headers. Context-out only: remote spans stitch via a shared collector, not the local store.
  • Limitations worth stating: interactive (tmux-pane) subagents are not stitched; detached background shells that outlive the CLI lose late spans.

Affected pages:

  • Telemetry/observability page: the propagation contract, the env vars, the local-first/remote-optional sink selection, the otel-cli and OTel SDK examples.
  • Agent/subagent docs: cross-process trace nesting.
  • infer traces reference (see [DOCS] Document infer traces command and /traces shortcut #390): mention that ingested child spans appear in the tree.

Source: inference-gateway/cli#909, inference-gateway/cli#904. Related: #390.

Acceptance Criteria

  • The telemetry docs document TRACEPARENT/TRACESTATE/BAGGAGE propagation to subprocesses and the OTLP sink selection (configured endpoint passthrough vs local ephemeral receiver).
  • An otel-cli example and an OTel SDK note show third-party spans landing in infer traces.
  • Subagent trace nesting and the A2A HTTP header propagation are documented, including the shared-collector requirement for remote spans.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    Fields

    No fields configured for Task.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions