What to record per call
Model, the four token counts, stop reason, latency, error if any, and the feature and user from your own request context. With prompt caching, cache reads are much cheaper than regular input, so cost per trace is only accurate if you store them separately.
Agents and tool use
An agent loop makes several Messages calls with tool calls in between. Log the whole loop as one trace, each model call as an llm span and each tool call as a tool span, and the trace explorer shows the loop step by step.