Current state
lex-trail is integrated (session events logged via trail_log). lex-log is NOT integrated — agent execution, tool calls, and LLM steps produce no spans or metrics.
Gap
lex-code is observability-dark at runtime:
- No span per agent turn (can't measure latency, identify slow tools)
- No metrics on tool success/failure rates
- No distributed trace correlation for multi-agent scenarios (multi_agent.lex)
- No log correlation between LLM steps and trail events
This means humans monitoring deployed lex-code instances can't verify runtime behaviour without reading logs — undermining the trust model.
What to add
Using lex-log/instrument.lex (already exists):
1. Per-turn span in session.lex
let scope := instrument.a2a_begin(ctx, session.id)
let result := run_turn_impl(session, input, provider_tag)
let scope2 := instrument.a2a_finish(scope, result.ok)
2. Per-tool-call span in agent dispatch
Each tool execution in lex-llm/agent.lex's dispatch loop should emit:
span.start("tool.execute") with tool_name attr
span.finish on completion with success attr
3. Metrics
counter("tool.calls", [("tool", name), ("success", "true|false")])
histogram("turn.duration_ms") per agent turn
4. Multi-agent trace propagation
multi_agent.lex spawns impl + test agents concurrently. Each should carry the parent trace context so their spans appear as children in the distributed trace.
Configuration
OTel export should be opt-in via env: LEX_OTLP_ENDPOINT=http://localhost:4318 (stdout JSON-lines if unset).
Current state
lex-trail is integrated (session events logged via
trail_log). lex-log is NOT integrated — agent execution, tool calls, and LLM steps produce no spans or metrics.Gap
lex-code is observability-dark at runtime:
This means humans monitoring deployed lex-code instances can't verify runtime behaviour without reading logs — undermining the trust model.
What to add
Using
lex-log/instrument.lex(already exists):1. Per-turn span in
session.lex2. Per-tool-call span in agent dispatch
Each tool execution in
lex-llm/agent.lex's dispatch loop should emit:span.start("tool.execute")withtool_nameattrspan.finishon completion withsuccessattr3. Metrics
counter("tool.calls", [("tool", name), ("success", "true|false")])histogram("turn.duration_ms")per agent turn4. Multi-agent trace propagation
multi_agent.lexspawns impl + test agents concurrently. Each should carry the parent trace context so their spans appear as children in the distributed trace.Configuration
OTel export should be opt-in via env:
LEX_OTLP_ENDPOINT=http://localhost:4318(stdout JSON-lines if unset).