feat(0.23.0): full distributed tracing + OTEL export#54
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/otel-export.ts) that batches and streams to any OTLP/HTTP collector viaOTEL_EXPORTER_OTLP_ENDPOINTenv var — no@opentelemetrySDK dependencysrc/mcp/trace-propagation.ts): child MCP processes readTRACE_ID+PARENT_SPAN_IDfrom env and join the parent trace treeValidationCtx.traceEmitter— optional field so validators that make LLM calls (e.g. LLM reviewer in coderProfile) emit spans; kernel passes it automaticallyExecCtx.traceId+ExecCtx.parentSpanId— cross-process correlation fieldsCall sites wrapped
traceEmitterintovalidate()ctx (1 site)Test plan
tests/otel-export.test.ts(6 tests): batch flush, env config, header propagation, shutdown drains, network failure resilience, span formattests/mcp/trace-propagation.test.ts(5 tests): env read, fresh trace generation, parent span reference, env serializationtests/loops/validator-tracing.test.ts(3 tests): validator receives emitter, undefined when not configured, can emit spanspnpm typecheckcleanpnpm test— 283 tests pass (16 new)pnpm buildclean