Skip to content
All tutors

Logging and Tracing LLM Calls

Record every model call and pipeline step so you can explain cost, slowness and bad answers.

By Skill Lab Intermediate Building with LLM APIs Evaluation and testing New

Your first 3 replies from the tutor are free. Then you can continue the lesson for $8 from your credit.

A taste of a lesson

One question and the answer, as this tutor gives it.

Logging and Tracing LLM Calls AI tutor following Skill Lab's plan
Student:

Some RAG answers take 20 seconds but I cannot tell why. What should I add?

Tutor:

Add tracing with a span per step. Create one trace per request, then a span around query rewriting, retrieval, reranking, the model call and any post processing, each with start and end times. On the model span also record input and output tokens, time to first token and retries. Then look at a few slow traces side by side: you will usually see one step dominating, often a long output, a retry or a slow search. Which steps does your pipeline have today?

Written with AI under Skill Lab's direction as an example. In your lesson the tutor answers your own questions, and like any AI it can be wrong. Right now the AI model is not connected: replies come from a built in test engine on this site.

What you will be able to do

  • Define the fields every model call log should contain
  • Trace multi step pipelines with spans for retrieval, model and tool calls
  • Log prompts and outputs responsibly with redaction, sampling and retention
  • Link user feedback to traces and build dashboards for cost and latency
  • Turn notable production traces into evaluation cases

Lesson plan

6 lessons. Pick one to start there.

  1. 1 Questions logs must answer List the production questions your logging should make easy. Start
  2. 2 The model call record Log a complete, structured record for every model call. Start
  3. 3 Traces and spans Trace a request across retrieval, model calls and tools. Start
  4. 4 Content, privacy and retention Decide what content to log and protect it properly. Start
  5. 5 Feedback and dashboards Connect user signals to traces and monitor the system. Start
  6. 6 From traces to evals Use production traces to improve your evaluation set. Start

Try asking

Tap a question to start a lesson with it.

About this tutor

For developers running LLM features in production who cannot yet answer simple questions: why was this answer wrong, why did this request take twenty seconds, which feature is spending the budget. You learn what to log for every model call, how to structure logs, how to trace multi step pipelines with spans for retrieval, model calls and tool calls, and how to handle prompt and output content responsibly with redaction, sampling, retention and access control. You also connect logs to user feedback and turn interesting traces into evaluation cases. Concepts follow open tracing standards and fit whichever observability tool you use.

Reviews

Students can review a tutor after a paid lesson. Nobody has yet.