<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents-yyuduwwqu" -->

---
title: Stop Guessing If Your AI Works: Tracing, Red Teaming,...
description: Microsoft Foundry adds OpenTelemetry tracing, automated evaluations with red teaming, and an Agent Optimizer to help developers verify AI agents before...
canonical: https://daily.dev/posts/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents-yyuduwwqu
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Stop Guessing If Your AI Works: Tracing, Red Teaming, and Auto-Optimizing Agents | daily.dev
og:description: Microsoft Foundry adds OpenTelemetry tracing, automated evaluations with red teaming, and an Agent Optimizer to help developers verify AI agents before...
og:url: https://daily.dev/posts/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents-yyuduwwqu
og:image: https://api.daily.dev/og/posts/YyuduWWQU.png
og:image:alt: Stop Guessing If Your AI Works: Tracing, Red Teaming, and Auto-Optimizing Agents
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Stop Guessing If Your AI Works: Tracing, Red Teaming, and Auto-Optimizing Agents

**[C\# Corner](https://daily.dev/sources/csharpcorner)** · 2 min read · 0 upvotes · 0 comments

## Summary

Microsoft Foundry adds OpenTelemetry tracing, automated evaluations with red teaming, and an Agent Optimizer to help developers verify AI agents before production. Tracing runs under the microsoft.foundry namespace and records every prompt, model thought, MCP tool call, token count, and latency metric. Two lines of code enable instrumentation, sending data to Azure Monitor Application Insights, viewable in the Foundry portal under Operate > Tracing. A Python example shows AIProjectInstrumentor enabling tracing for a gpt-5-mini call.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.c-sharpcorner.com/article/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents>

## Questions this post answers

### How do I enable OpenTelemetry tracing for AI agents in Microsoft Foundry?

Use the AIProjectInstrumentor from azure.ai.projects.telemetry and call instrument(enable_content_recording=True) after setting up a standard OpenTelemetry TracerProvider with a span processor. This records every prompt, model thought, MCP tool call, token count, and latency metric under the microsoft.foundry tracing namespace, sending data to Azure Monitor Application Insights, viewable in the Foundry portal under Operate > Tracing.

_Developers debugging flaky agent behavior can keep up with Azure AI tooling changes like this on daily.dev._

### What information does Microsoft Foundry's tracing capture for an agent call?

It captures every prompt, model 'thought', MCP tool call, token count, and latency metric as nested spans, such as an agent invocation span containing memory lookup, tool call, and model generation sub-spans. One example shows a gpt-5-mini model generation span taking 1,025ms and consuming 412 tokens within a 1,420ms total agent invocation.

_Teams tuning agent latency and token costs can track tracing updates like this via daily.dev._

## Similar posts on daily.dev

- [Build 2026: From observability to ROI for AI agents on any framework](https://daily.dev/posts/build-2026-from-observability-to-roi-for-ai-agents-on-any-framework-yzhrlbhaa) · DevBlogs · 1 upvotes · 0 comments
- [Building AI apps and agents with Microsoft Foundry](https://daily.dev/posts/building-ai-apps-and-agents-with-microsoft-foundry-tdq7h47dl) · InfoWorld · 0 upvotes · 0 comments
- [Let Microsoft Foundry Improve Your Agent: A Practical Guide to the Agent Optimizer](https://daily.dev/posts/let-microsoft-foundry-improve-your-agent-a-practical-guide-to-the-agent-optimizer-ji6u2cfhn) · C\# Corner · 0 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#azure](https://daily.dev/tags/azure), [#microsoft-foundry](https://daily.dev/tags/microsoft-foundry), [#observability](https://daily.dev/tags/observability), [#opentelemetry](https://daily.dev/tags/opentelemetry)

[View this post on daily.dev](https://daily.dev/posts/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents-yyuduwwqu)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Stop Guessing If Your AI Works: Tracing, Red Teaming, and Auto-Optimizing Agents","url":"https://daily.dev/posts/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents-yyuduwwqu","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents-yyuduwwqu"},"datePublished":"2026-10-26T03:46:57.690Z","dateModified":"2026-10-29T02:14:12.125Z","description":"Microsoft Foundry adds OpenTelemetry tracing, automated evaluations with red teaming, and an Agent Optimizer to help developers verify AI agents before...","image":"https://media.daily.dev/image/upload/s--OHB84bZF--/f_auto/v1722860399/public/Placeholder%2010","thumbnailUrl":"https://media.daily.dev/image/upload/s--OHB84bZF--/f_auto/v1722860399/public/Placeholder%2010","isAccessibleForFree":true,"articleSection":"C# Corner","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"C# Corner","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ada2d584df6241748fc4e71878dc70a3","url":"https://daily.dev/sources/csharpcorner"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents-yyuduwwqu","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-agents,azure,microsoft-foundry,observability,opentelemetry","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"C# Corner","item":"https://daily.dev/sources/csharpcorner"},{"@type":"ListItem","position":3,"name":"Stop Guessing If Your AI Works: Tracing, Red Teaming, and Auto-Optimizing Agents"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/stop-guessing-if-your-ai-works-tracing-red-teaming-and-auto-optimizing-agents-yyuduwwqu#faq","mainEntity":[{"@type":"Question","name":"How do I enable OpenTelemetry tracing for AI agents in Microsoft Foundry?","acceptedAnswer":{"@type":"Answer","text":"Use the AIProjectInstrumentor from azure.ai.projects.telemetry and call instrument(enable_content_recording=True) after setting up a standard OpenTelemetry TracerProvider with a span processor. This records every prompt, model thought, MCP tool call, token count, and latency metric under the microsoft.foundry tracing namespace, sending data to Azure Monitor Application Insights, viewable in the Foundry portal under Operate \u003e Tracing. Developers debugging flaky agent behavior can keep up with Azure AI tooling changes like this on daily.dev."}},{"@type":"Question","name":"What information does Microsoft Foundry's tracing capture for an agent call?","acceptedAnswer":{"@type":"Answer","text":"It captures every prompt, model 'thought', MCP tool call, token count, and latency metric as nested spans, such as an agent invocation span containing memory lookup, tool call, and model generation sub-spans. One example shows a gpt-5-mini model generation span taking 1,025ms and consuming 412 tokens within a 1,420ms total agent invocation. Teams tuning agent latency and token costs can track tracing updates like this via daily.dev."}}]}
```

