Lesson 2 of 4 Compute, Observability and Developer Tooling

Making Agent Runs Observable with Tracing, Reasoning Logs and Replay

This lesson describes the components that let engineers see every step of a long, branching, nondeterministic multi-agent run across services, understand why each decision was made and, ideally, reproduce the run.

Learning outcomes

After completing this lesson, you will be able to:

  • Correlate traces across services with OpenTelemetry.
  • Design structured logs of reasoning paths.
  • Capture what is needed to replay a failed run.

Cross-service trace correlation

OpenTelemetry is the standard for traces, metrics and logs. A trace is a tree of spans, each representing an operation such as an agent invocation, a model call or a tool call. W3C Trace Context headers (traceparent) carry the trace ID across HTTP calls, so spans from the orchestrator, remote agents, MCP servers and back-end APIs join one trace. Messages on Service Bus carry the context in their properties.

Foundry and Agent Framework emit spans that follow the OpenTelemetry GenAI semantic conventions (operation names such as invoke_agent, chat and execute_tool, with token usage attributes). Exporting to Application Insights makes the whole trace queryable in one place and visible in the Foundry portal.

The following diagram shows the spans of one trace across services.

One trace across services. OpenTelemetry represents a run as a tree of spans: the orchestrator's agent invocation, model calls, a remote agent's invocation, an MCP tool call and the back-end API behind it. W3C Trace Context headers (traceparent) carry the trace ID across HTTP calls, and Service Bus messages carry it in their properties, so every span joins one trace. Spans follow the GenAI semantic conventions and are exported to Application Insights.
Durations are illustrative.
Match the pairs

GenAI spans

Exam skills 1.2.5

Match each OpenTelemetry GenAI operation name with what the span represents.

Log in to try this activity Interactive activities are free with an account.

Structured logging of reasoning paths

Traces show what happened; reasoning logs show why. A structured log entry per decision records the agent, workflow step, options considered, chosen tool or hand-off target, arguments, result status and a short reasoning summary (for reasoning models, the provided reasoning summary rather than raw hidden reasoning). Typed fields allow queries such as "how often does the triage agent route refunds to the billing agent?" Personal data in logs is minimized or redacted.

Select all that apply

What a reasoning log entry records

Exam skills 1.2.5

Pick the fields a structured reasoning log entry should contain.

Log in to try this activity Interactive activities are free with an account.

Agent replay capture

Re-running a failed request rarely reproduces the failure, because model outputs, tool data and timing differ. Replay capture records what is needed to re-execute the run deterministically or near-deterministically, as the following list shows.

  • The exact inputs, including user messages and injected context.
  • Versions of the agent, prompt templates, model deployment and tools.
  • Tool and retrieval results as returned at the time.
  • Model settings such as temperature, reasoning effort and seed where supported.

A replay harness substitutes the recorded tool results for live calls and re-runs the agent, so engineers can test a fix against the exact failing situation. Captures contain sensitive data, so they are stored with access control and retention limits.

True or false

Replaying a failed run

Exam skills 1.2.5

Check what replay capture records and how it is used.

Log in to try this activity Interactive activities are free with an account.
Worked example

An intermittent wrong refund

About once a week, a refund agent refunds the wrong order. Logs show only the final tool call. Engineers cannot reproduce the problem by resubmitting the same message.

Replay capture of the order lookup results and agent versions, together with structured logs of which order the agent selected and why, would allow the failing run to be re-executed with the same data. The likely cause, such as an ambiguous lookup returning two orders, can then be confirmed and fixed. Increasing log verbosity alone would still not reproduce the tool data the agent saw.

Check yourself

What is needed to see one trace across several services?

Show answer

W3C Trace Context propagation, so every service records its spans under the same trace.

Exam Tips

Remember for the exam

  • One trace across services needs W3C Trace Context propagation.
  • Log decisions as typed fields, with personal data minimized.
  • Replay needs recorded tool results and versions, stored securely.