-
Notifications
You must be signed in to change notification settings - Fork 2
fix(debug): native tool span startTimeUnixNano records post-execution time #1798
Description
Problem
In native.rs, begin_tool_call is called after tool execution (post-hoc assembly pattern), so startTimeUnixNano records the time after the tool has finished rather than when it started. Latency is measured correctly via started_at.elapsed(), but the absolute span start timestamp is off.
Impact
When viewing traces in Jaeger/Grafana, native tool spans will appear to start at the wrong time. The duration is correct, but the span's position on the timeline is shifted by the tool execution duration.
Suggested fix
Record start_time = Instant::now() before calling the tool, then pass it to begin_tool_call (or use an explicit started_at field). The constraint is the post-hoc assembly pattern in handle_native_tool_calls.
Context
Found during code review of #1797 (OTel trace debug dumps). Flagged as OBS-02 by reviewer — non-blocking for the initial feature but worth fixing for accurate timeline visualization.