Tracing, debugging, evaluation
Already exporting OpenTelemetry to Application Insights and scoring answers? Skip to the next lesson.
Your agent gives a wrong answer. Where do you even look? A model call is not a crash. There is no stack trace. This lesson is about seeing inside.
Tracing
Tracing records what happened during a run: which model calls were made, which tools ran, how long each took, what came back.
OpenTelemetry is the standard way of recording that, used across the industry and not specific to Azure. Application Insights is where those records land inside Azure, and where you can search them afterwards.
You have been using a trace all along. The panel on the right of every lesson is one. Now you wire the real thing.
The failure that looks like success
Here is the one worth remembering.
Your tool runs. It returns successfully. Your dashboard is green. And the model's answer ignores what the tool said completely.
That happens when the result never made it back into the conversation, which is the mistake Module 2 warned about. Every metric says fine. The answer is wrong. A green tool call proves the tool ran, and nothing more.
Evaluation
Evaluation is scoring answers instead of eyeballing them.
Groundedness is the most useful score to start with: how much of the answer is actually supported by the sources retrieved. It turns "seems alright" into a number you can set a floor under and refuse to ship below.
What to write
OTEL_ENABLED = TrueAPPINSIGHTS_CONNECTION, a connection string startingInstrumentationKey=EVAL_GROUNDEDNESS = 4or higher- Dispatch
lookup_policyand feed its result back before the nextchat
The point
You cannot debug what you cannot see, and a successful tool call does not mean the result was used.
Break it on purpose
Leave the tool result out of messages. The trace shows the tool ran fine.
The check still fails. Sit with that for a second: that is a bug that would
pass every dashboard you own.
Check yourself
Answer out loud first. Reading the answer without trying is where the learning leaks out.
1. Where do OTEL spans go in this lab's Azure story?
2. What does a high tool success rate fail to prove?
3. Why score groundedness before you ship?