mediumAI Engineering

What should you log and trace in an LLM application?

41 views
01

Understand the problem

Observability for nondeterministic systems: traces, token metrics, and quality signals.

observabilitytracingloggingllmops
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

Read the code

Trace record worth its storage
await traces.write({
  id: reqId, feature: "support-answer", tenant: ctx.tenantId,
  promptVersion: "support-answer@v42",
  model, params: { temperature: 0.2, maxTokens: 800 },
  renderedPrompt: scrubPii(rendered),          // exact bytes, scrubbed
  retrieved: chunks.map((c) => ({ id: c.id, score: c.score })),
  toolCalls: trace.tools,                       // name, args-hash, ok/err, ms
  output: scrubPii(reply.text),
  usage: reply.usage, latencyMs, costUsd,
  feedback: null,                               // thumbs join later → eval candidates
});
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.