When you write traditional software, testing is easy. If a function is supposed to add 2 + 2 and it returns 4, your unit test turns green and you deploy on Friday afternoon with zero stress.
With AI agents, developers often fall into the "vibe check" trap. They type three test questions into a chat window, the answers look pretty good, and they push the agent to production. Two days later, a customer asks a slightly tricky question, the agent calls the wrong API, or a clever user tricks the agent into ignoring its instructions.
To run AI in production with confidence, you need three things built directly into Microsoft Foundry: OpenTelemetry Tracing, Automated Evaluations & Red Teaming, and the Agent Optimizer.
1. X-Ray Vision with OpenTelemetry Tracing
When an agent takes eight seconds to reply or gives a weird answer, you need to know why. Did the search tool return bad documents? Did the model misunderstand the tool schema? Or did an external API time out?
Microsoft Foundry uses OpenTelemetry (OTel) under themicrosoft.foundry tracing namespace. By turning on instrumentation in two lines of code, every single prompt, model thought, MCP tool call, token count, and latency metric is recorded and sent to Azure Monitor Application Insights (visible right inside the Foundry portal under Operate > Tracing).
[ User Prompt ]
|
+---> Span 1: Agent Invocation (Total: 1,420ms)
|---> Span 2: Memory Lookup (85ms)
|---> Span 3: MCP Tool Call - SearchIndex (310ms)
+---> Span 4: Model Generation - gpt-5-mini (1,025ms | 412 tokens)
Python Example: Turning On Full Agent Tracing
from azure.ai.projects import AIProjectClient
from azure.ai.projects.telemetry import AIProjectInstrumentor
from azure.identity import DefaultAzureCredential
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter
# 1. Set up standard OpenTelemetry exporter (or AzureMonitorTraceExporter for cloud portal)
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
trace.set_tracer_provider(provider)
# 2. Enable Microsoft Foundry tracing (including prompt and tool call content)
AIProjectInstrumentor().instrument(enable_content_recording=True)
project = AIProjectClient(
endpoint="https://your-resource.services.ai.azure.com/api/projects/your-project",
credential=DefaultAzureCredential(),
)
# Every agent or model call below is now automatically traced!
openai_client = project.get_openai_client()
response = openai_client.responses.create(
model="gpt-5-mini",
input="Summarize our uptime SLA in one sentence.",
)
print(response.output_text)
Join the conversation! Your thoughts help the community grow.