bruteSourceBruteMiddlewareTracing

class Tracing

Logs timing and token usage for every LLM call, and tracks cumulative timing data in env[:metadata][:timing].

As the outermost middleware, it sees the full pipeline elapsed time per call. It also tracks total wall-clock time across all calls in a turn (including tool execution gaps between LLM calls).

A new turn is detected when env[:current_iteration] == 1 (the agent loop resets this at the start of each turn).

Stores in env[:metadata][:timing]: total_elapsed: wall-clock since the turn began (includes tool gaps) total_llm_elapsed: cumulative time spent inside LLM calls only llm_call_count: number of LLM calls so far last_call_elapsed: duration of the most recent LLM call