const res = await llm(messages);
console.log('LLM call', messages, res.text);const start = Date.now();
const res = await llm(messages);
logger.info('llm_call', {
model: res.model,
inputTokens: res.usage.input_tokens,
outputTokens: res.usage.output_tokens,
latencyMs: Date.now() - start,
prompt: redact(messages),
});Structured logs with model, tokens and latency make calls searchable, and redaction keeps personal data out of stored prompts.
Regular monitoring tracks uptime and errors. AI observability also records prompts, outputs, tool calls, tokens and cost, so you can see why a model behaved a certain way.
A trace is the record of one request as a tree of steps, such as model calls, retrieval and tool calls, with their inputs, outputs and timing.
Only after redacting secrets and personal data, and with user consent where required. Limit who can read the logs and how long they are kept.