Skip to content

fix(debug): native tool span startTimeUnixNano records post-execution time #1798

@bug-ops

Description

@bug-ops

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions