Skip to content

feat(0.23.0): full distributed tracing + OTEL export#54

Merged
drewstone merged 2 commits into
mainfrom
feat/trace-everything-otel-export
May 25, 2026
Merged

feat(0.23.0): full distributed tracing + OTEL export#54
drewstone merged 2 commits into
mainfrom
feat/trace-everything-otel-export

Conversation

@tangletools
Copy link
Copy Markdown
Contributor

Summary

  • OTEL span exporter (src/otel-export.ts) that batches and streams to any OTLP/HTTP collector via OTEL_EXPORTER_OTLP_ENDPOINT env var — no @opentelemetry SDK dependency
  • MCP trace propagation (src/mcp/trace-propagation.ts): child MCP processes read TRACE_ID + PARENT_SPAN_ID from env and join the parent trace tree
  • ValidationCtx.traceEmitter — optional field so validators that make LLM calls (e.g. LLM reviewer in coderProfile) emit spans; kernel passes it automatically
  • ExecCtx.traceId + ExecCtx.parentSpanId — cross-process correlation fields

Call sites wrapped

  • Kernel → validator: passes traceEmitter into validate() ctx (1 site)
  • MCP bin: reads trace context from env, creates propagating emitter (2 sites)
  • loopEventToOtelSpan: converts any LoopTraceEvent to OTLP span (utility)

Test plan

  • tests/otel-export.test.ts (6 tests): batch flush, env config, header propagation, shutdown drains, network failure resilience, span format
  • tests/mcp/trace-propagation.test.ts (5 tests): env read, fresh trace generation, parent span reference, env serialization
  • tests/loops/validator-tracing.test.ts (3 tests): validator receives emitter, undefined when not configured, can emit spans
  • pnpm typecheck clean
  • pnpm test — 283 tests pass (16 new)
  • pnpm build clean

drewstone added 2 commits May 24, 2026 16:18
…hape

The 0.22.0 OpenAI-compat backend accepts `tools[]` + `toolChoice` but does
not auto-discover MCP tools from a parent sandbox's profile. Callers that
route through tcloud / cli-bridge / OpenRouter / OpenAI direct must hand
the model an explicit OpenAI Chat Completions `tools[]` array.

`mcpToolsForRuntimeMcp()` returns the canonical projection of the 5
delegation tools (delegate_code, delegate_research, delegate_feedback,
delegation_status, delegation_history) wired off the existing
DELEGATE_*_TOOL_NAME / DELEGATE_*_DESCRIPTION / DELEGATE_*_INPUT_SCHEMA
constants so the projection cannot drift from the server's validators.

`mcpToolsForRuntimeMcpSubset(names)` returns a curated filter for callers
that want a partial mount (e.g. read-only history without the coder queue).

Sandbox-SDK callers do not need this helper — the sandbox runtime mounts
MCP servers natively and the in-sandbox harness discovers tools via the
runtime, not the OpenAI tools array.
- Add OTEL span exporter (src/otel-export.ts) that streams to any
  OTLP/HTTP collector via OTEL_EXPORTER_OTLP_ENDPOINT env var
- Add MCP trace propagation (src/mcp/trace-propagation.ts): read TRACE_ID
  + PARENT_SPAN_ID from env so child MCP processes join the parent trace
- Extend ValidationCtx with optional traceEmitter so validators that make
  LLM calls can emit spans into the trace tree
- Add traceId + parentSpanId fields to ExecCtx for cross-process correlation
- Kernel passes traceEmitter to validator.validate() automatically
@drewstone drewstone merged commit f721694 into main May 25, 2026
0 of 2 checks passed
@drewstone drewstone deleted the feat/trace-everything-otel-export branch May 25, 2026 08:10
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.

2 participants