Skip to content

feat: OTel GenAI trace chain (P1.3) - #247

Merged
dahai80 merged 1 commit into
mainfrom
feat/p1-3-otel-chain
Nov 12, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/p1-3-otel-chain

Conversation

@dahai80

@dahai80 dahai80 commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Summary

Evolution plan P1.3 (docs/evolution-plan-2026-11.md, C9): OTel GenAI trace chain — the missing observability link.

  • Minimal OTLP/JSON exporter over fetch (src/utils/telemetry/otelTracing.ts) — no exporter dependency, single-binary distribution intact.
  • Spans: fusion.turn (QueryEngine turn boundary), gen_ai.tool (tool execution), gen_ai.llm (streaming via the streamViaSeam chokepoint + non-streaming createMessage with token usage), fusion.budget.check (budget funnel).
  • GenAI semconv attributes: gen_ai.request.model, gen_ai.usage.input_tokens / output_tokens, gen_ai.tool.name; child spans inherit fusion.turn.id.
  • Default-off (FUSION_CODE_OTEL_ENDPOINT, localhost-only, no default remote endpoint — no-telemetry-egress defense line intact); flush per span end (headless process.exit outruns timers); export failures fail-open. Off = byte-identical.

Test plan

  • bun run typecheck clean
  • bun run check green (lint / layers / flags / build)
  • bun test src/__tests__/ 1265 pass (incl. 8 new otelTracing tests)
  • bun test ./tests/ 347 pass
  • E2E: one headless run against a mock Anthropic endpoint emits fusion.turn + gen_ai.tool + gen_ai.llm (42/7 token attrs) + fusion.budget.check all sharing one fusion.turn.id

Closes evolution plan item P1.3 (Phase 1 exit: v0.6.0 after merge).

🤖 Generated with Claude Code

Minimal OTel/JSON exporter with zero new dependencies: turn span
(QueryEngine), tool span (runToolUse), LLM span (streamViaSeam seam
chokepoint + createMessage with token usage), budget funnel span
(checkBudget). GenAI semconv attributes; child spans inherit
fusion.turn.id from the active turn. Default-off via
FUSION_CODE_OTEL_ENDPOINT (localhost-only, no default remote endpoint);
flush per span end so headless runs that process.exit don't lose the
batch; export failures fail-open. Off = byte-identical.

Verified end-to-end: one headless run against a mock Anthropic endpoint
emits fusion.turn + gen_ai.tool + gen_ai.llm (input/output token attrs)
+ fusion.budget.check all sharing one fusion.turn.id.

Co-Authored-By: Claude Code <[email protected]>
@dahai80
dahai80 merged commit 2bf3261 into main Nov 12, 2026
2 checks passed
@dahai80
dahai80 deleted the feat/p1-3-otel-chain branch November 12, 2026 09:51
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