Repository navigation
Description
Summary
The internal/telemetry package currently records the metrics signal only
(gen_ai.* + infer.* instruments via the OTel SDK, exported to a local
OTLP/semconv file and, opt-in, pushed over OTLP/HTTP). The package was
deliberately named "telemetry" rather than "metrics" to leave room for the
other OTel signals. This issue tracks adding traces and logs so the CLI
becomes the single telemetry engine for all three signals.
Direction: the CLI is the one place telemetry is produced and it is fully
configurable via the standard OTel environment variables. Downstream consumers
(infer-action, CI, operators) only set env vars and run infer - they never
re-implement export. The metrics path already honors
OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, OTEL_SERVICE_NAME,
and OTEL_RESOURCE_ATTRIBUTES; traces and logs must follow the same pattern and
share the same resource.
Traces
A trace makes an agent run legible end to end: one root span per session, child
spans for each LLM stream and each tool call, so latency and failures attribute
to a specific step instead of being read off an aggregate counter.
Proposed span shape (GenAI semconv):
- Root:
sessionspan -infer.execution.mode, agent mode,infer.run.outcome, duration. - Child:
chat <model>per LLM turn -gen_ai.request.model,gen_ai.provider.name, token usage. - Child:
execute_tool <name>per tool call -gen_ai.tool.name,gen_ai.tool.type=function,infer.tool.outcome,error.type.
W3C trace-context propagates to the gateway so CLI spans link to gateway spans.
Logs
Emit the CLI's structured logs through the OTel logs signal (OTLP), correlated
to the active trace/span, so a run's metrics, spans, and logs share one resource
and one correlation id. Local-first: a file exporter when no endpoint is set.
Shared with metrics
- Same resource (
service.name,service.version,infer.execution.mode+ env attrs). - Same endpoint/headers config (
telemetry.otlp.*/OTEL_EXPORTER_OTLP_*). - Local-first, remote opt-in, delta temporality, no prompt/response content recorded.
- Zero overhead when
telemetry.enabled=false.
Acceptance Criteria
- Tracer provider wired in
internal/telemetrysharing the resource and OTLP endpoint/headers config with the meter provider. - Session root span with per-LLM-turn and per-tool-call child spans, GenAI semconv names/attributes, no prompt/response content.
- W3C trace-context propagated to the gateway so CLI spans link to gateway spans.
- Logger provider wired: CLI structured logs exported via OTLP logs, correlated to the active span; local file export when no endpoint is set.
- All three signals honor
OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_HEADERS,OTEL_SERVICE_NAME,OTEL_RESOURCE_ATTRIBUTES; zero overhead when disabled. -
[DOCS]follow-up filed againstinference-gateway/docsfor tracing/logs config + example collector setup.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
edenreich commentedon Jul 13, 2026
@infer Can you work on this? use /go /go-concurrency /ponytail:ponytail
inference-gateway-maintainer commentedon Jul 13, 2026
Model:
ollama_cloud/deepseek-v4-flash· View JobTodos
Pull Request
#901
✅ Infer Result: Success
The implementation is complete and all acceptance criteria are met. The draft PR #901 is open on the
fix/issue-893branch with all changes committed and pushed.Model:
ollama_cloud/deepseek-v4-flash· Exit Code:0· Duration: 22m 3sTokens: 11,302,153 in · 32,347 out · 11,334,500 total (65 requests)
Tool calls: 76 total · 96% success rate
Triggered by edenreich · Infer Action
feat(telemetry): wire session and LLM-turn trace spans end-to-end
feat(telemetry): wire session and LLM-turn trace spans end-to-end
feat(telemetry): add traces and logs to the telemetry package (#901)
feat(telemetry): add infer traces command and /traces shortcut (#908)