Implementation Plan for Simplified Agent Observability Showcase
Plans a simplified agent observability showcase by removing PII masking, Terraform, and 39+ dependencies, then rebuilding with Azure AI Foundry and OpenTelemetry.
What this file does
Plans a simplified agent observability showcase by removing PII masking, Terraform, and 39+ dependencies, then rebuilding with Azure AI Foundry and OpenTelemetry.
When to use it
- You want to strip a complex observability demo down to its essentials
- You need a blueprint for integrating Azure AI Foundry agents with OpenTelemetry
- You are replacing Terraform with Azure CLI for infrastructure provisioning
- You want to remove PII masking from an existing telemetry codebase
Assumes this stack
Implementation Plan for Simplified Agent Observability Showcase
This document outlines a detailed implementation plan to create a simplified version of the Agent Observability Showcase project. The focus is on removing PII masking, simplifying dependencies, and implementing a basic agent with telemetry features.
π Comprehensive Implementation Plan
Follow this plan and ask clarifying questions if needed.
Repository Structure (After Simplification)
agent-observability/
βββ src/
β βββ main.py # FastAPI application (NEW)
β βββ agent.py # Simple agent implementation (NEW)
β βββ backend/core/
β βββ telemetry.py # β
Keep (remove PII refs)
β βββ telemetry_decorators.py # β
Keep (remove mask_pii)
β βββ telemetry_api_dependencies.py # β
Keep
β βββ logging.py # β
Keep (remove PIIMaskingFilter)
βββ scripts/
β βββ provision.sh # Azure infra script (NEW)
β βββ generate_test_telemetry.py # β
Update (remove Terraform)
β βββ restore.sh # β
Keep
β βββ utils.sh # β
Keep
βββ pyproject.toml # β
Massive cleanup
βββ Makefile # β
Simplify targets
βββ README.md # β
Complete rewrite
βββ .env.example # NEW
Phase 1. Simple Agent Implementation Design
Agent Architecture
Use Azure AI Foundry with GPT-4.1 deployment (following ai-foundry-demo pattern)
Agent Features (src/agent.py)
class SimpleAgent:
"""
Azure AI Foundry agent demonstrating telemetry in multi-step workflows.
Uses Azure AI Agents SDK with GPT-4.1 deployment for realistic agent behavior.
Steps:
1. Planning (@trace_agent_step) - Analyze user query, decide tools
2. Tool Execution (@track_tool_execution) - Execute selected tools with Azure Functions
3. Response Generation (@track_tokens) - Generate response using GPT-4.1
Tools (as Azure Functions):
- web_search: Simulates web search with random results
- calculator: Simple math operations
- weather: Mock weather data
Configuration:
- Uses AgentsClient from azure.ai.agents
- Connects to AI Foundry project endpoint
- Configured via settings (ai_foundry_project_endpoint, gpt_4_1_deployment_name)
"""
Demo Endpoints (src/main.py)
POST /api/chat - Full agent conversation with tool execution
POST /api/plan - Just the planning step (shows @trace_agent_step)
POST /api/tool/search - Individual tool execution (shows @track_tool_execution)
POST /api/generate - LLM response using GPT-4.1 (shows @track_tokens)
GET /health - Health check with APITelemetry
GET /api/agent/status - Agent configuration and status
Phase 2. PII Masking Removal Strategy
Files to Modify
telemetry_decorators.py
- Remove
from src.backend.core.pii_masking import mask_piiimport - In
trace_agent_step: Removemask_pii()calls, pass kwargs directly to span - In
track_tool_execution: Removemask_pii()calls, pass values directly - Remove
pii_paramsparameter fromtrack_tool_execution(no longer needed) - Update docstrings to remove PII references
logging.py
- Remove entire
PIIMaskingFilterclass (lines 66-136) - Remove
pii_mask_enabledandpii_mask_levelparameters fromsetup_logging() - Remove filter setup code (lines 388-395)
telemetry.py
- Remove docstring references to
pii_maskingmodule
Phase 3. Dependencies Cleanup
pyproject.toml - KEEP ONLY
[tool.poetry.dependencies]
python = ">=3.13,<3.14"
# Core FastAPI
fastapi = {version = "^0.119.0", extras = ["standard"]}
pydantic = "^2.11.9"
pydantic-settings = "^2.10.1"
httpx = "^0.28.1"
# Azure AI Foundry & Agents
azure-identity = "^1.25.0"
azure-ai-agents = ">=1.2.0b2"
# Telemetry
opentelemetry-sdk = "^1.37.0"
opentelemetry-api = "^1.37.0"
azure-core-tracing-opentelemetry = "^1.0.0b12"
# Utilities
orjson = "^3.11.3"
python-dotenv = "^1.1.0"
[tool.poetry.group.dev.dependencies]
ruff = "^0.11.6"
mypy = "^1.8.0"
pytest = "^8.4.0"
pytest-asyncio = "^1.0.0"
pytest-cov = "^6.1.1"
pytest-httpx = "^0.35.0"
REMOVE EVERYTHING ELSE: 39+ unnecessary dependencies!
Phase 4. provision.sh Script Design
Interactive Prompts
# Prompt with defaults
read -p "Project name [agent-observability]: " PROJECT_NAME
PROJECT_NAME=${PROJECT_NAME:-agent-observability}
read -p "Azure region [uaenorth]: " REGION
REGION=${REGION:-uaenorth}
read -p "Environment [dev]: " ENVIRONMENT
ENVIRONMENT=${ENVIRONMENT:-dev}
Azure CAF Naming Convention
# Resource names
RG_NAME="rg-${PROJECT_NAME}-${ENVIRONMENT}"
LOG_NAME="log-${PROJECT_NAME}-${ENVIRONMENT}"
APPI_NAME="appi-${PROJECT_NAME}-${ENVIRONMENT}"
Idempotent Operations
# Check if resource group exists
if az group exists --name "$RG_NAME" | grep -q "true"; then
echo "β Resource group already exists"
else
echo "Creating resource group..."
az group create --name "$RG_NAME" --location "$REGION"
fi
Output to .env
# Create or update .env file
cat > .env << EOF
# Azure Application Insights
APPLICATIONINSIGHTS_CONNECTION_STRING="${CONN_STRING}"
# Azure AI Foundry (user must configure manually)
AI_FOUNDRY_NAME=
AI_FOUNDRY_PROJECT_NAME=
GPT_4_1_DEPLOYMENT_NAME=
# Service Configuration
LOG_LEVEL=INFO
ENVIRONMENT=${ENVIRONMENT}
SERVICE_NAME=${PROJECT_NAME}-api
EOF
echo ""
echo "β
.env file created successfully"
echo "β οΈ Please configure AI Foundry settings in .env:"
echo " - AI_FOUNDRY_NAME (your AI Foundry resource name)"
echo " - AI_FOUNDRY_PROJECT_NAME (your project name)"
echo " - GPT_4_1_DEPLOYMENT_NAME (your GPT-4.1 deployment name)"
Phase 5. generate_test_telemetry.py Updates
Remove
- All Terraform fallback logic (lines 371-414)
- Subprocess imports and logic
- References to "make provision" (replace with "./scripts/provision.sh")
Simplify get_connection_string()
def get_connection_string() -> str | None:
"""Get Application Insights connection string from .env file."""
# Load from .env file
from dotenv import load_dotenv
load_dotenv()
conn_str = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if conn_str:
return conn_str
print("β οΈ Connection string not found in .env file")
print(" Run: ./scripts/provision.sh to create Azure resources")
return None
Phase 6. Makefile Simplification
KEEP THESE TARGETS
help # Keep
restore # Keep
# Infrastructure
provision # Keep - runs ./scripts/provision.sh
# Code Quality
format format-check # Keep
lint fix # Keep
# Testing
test test-cov # Keep
# Application
run-api # Keep - runs uvicorn
# Observability
test-telemetry # Keep
test-telemetry-normal # Keep
test-telemetry-errors # Keep
test-telemetry-spikes # Keep
test-telemetry-batch # Keep
test-telemetry-load # Keep
REMOVE THESE TARGETS
# Remove ALL of these
register-providers
setup-remote-state
enable-remote-state-access
generate-env
enable-ai-foundry-access
setup-github-sp
configure-github
verify-sp
rotate-secrets
setup-cd
run-frontend
chat
test-stt
transcribe*
rag-*
config-*
compliance-*
eval-*
Phase 7. README.md Structure
# Agent Observability Showcase
Simple FastAPI application demonstrating OpenTelemetry integration with Azure Monitor.
## Features
- β
FastAPI with OpenTelemetry decorators
- β
Simple agent with multi-step workflows
- β
Azure Application Insights integration
- β
Automatic trace, metrics, and logs correlation
- β
Test telemetry data generator
## Quick Start
### 1. Provision Azure Infrastructure
./scripts/provision.sh
### 2. Install Dependencies
make restore
### 3. Run the API
make run-api
### 4. Generate Test Data
make test-telemetry
### 5. View in Azure Portal
[Link to Application Insights]
## API Endpoints
[Document endpoints]
## Architecture
[Simple diagram]
Phase 8. .env.example
# Azure Application Insights
APPLICATIONINSIGHTS_CONNECTION_STRING=
# Azure AI Foundry Configuration
AI_FOUNDRY_NAME=
AI_FOUNDRY_PROJECT_NAME=
GPT_4_1_DEPLOYMENT_NAME=
# Logging Configuration
LOG_LEVEL=INFO
# Service Configuration
ENVIRONMENT=dev
SERVICE_NAME=agent-observability-api
Implementation Order & Estimates
- Clean pyproject.toml β - Added azure-ai-agents dependency
- Remove PII masking - Clean 3 files
- Create provision.sh - Interactive Azure CLI script
- Update generate_test_telemetry.py - Remove Terraform logic
- Create simple agent - Azure AI Foundry agent with 3 tools
- Create src/core/config.py for AI Foundry settings
- Create src/agent.py using AgentsClient pattern
- Implement 3 tools as function definitions
- Create FastAPI app - 6 endpoints with telemetry
- Simplify Makefile - Remove 25+ targets
- Create .env.example - 7 variables (added AI Foundry config)
- Rewrite README - Complete documentation with AI Foundry setup
- Test end-to-end - Verify everything works
AI Foundry Implementation Notes
Key Components from ai-foundry-demo
-
Settings/Config (src/core/config.py):
class Settings(BaseSettings): ai_foundry_name: str ai_foundry_project_name: str gpt_4_1_deployment_name: str @property def ai_foundry_project_endpoint(self) -> str: return f"https://{self.ai_foundry_name}.services.ai.azure.com/api/projects/{self.ai_foundry_project_name}" -
Agent Client (src/agent.py):
from azure.ai.agents import AgentsClient from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential() agents_client = AgentsClient( endpoint=settings.ai_foundry_project_endpoint, credential=credential ) -
Agent Creation:
agent = agents_client.create_agent( model=settings.gpt_4_1_deployment_name, name="Simple_Agent", instructions="System prompt here...", tools=[tool_definitions] # Functions for web_search, calculator, weather ) -
Thread & Execution:
thread = agents_client.threads.create() agents_client.messages.create(thread_id=thread.id, role="user", content=query) with agents_client.runs.stream(thread_id=thread.id, agent_id=agent.id) as stream: stream.until_done()
Key Benefits of This Approach
β
Simple: One agent, clear purpose
β
Realistic: Uses actual Azure AI Foundry with GPT-4.1 deployment
β
Complete: Demonstrates all telemetry features with real agent interactions
β
Production-ready: Proper Azure CAF naming and AI Foundry integration
β
Idempotent: Safe to run provision.sh multiple times
β
No Terraform: Pure Azure CLI
β
No PII complexity: Clean and focused
β
Real AI: Actual GPT-4.1 responses with Azure AI Agents SDK
What's inside
8 phases, 6 code blocks, 3 file modification lists, 1 Makefile diff, 1 README structure
Change this for your project
- Replace
macromania/agent-observabilitywith your own repository name - Replace
uaenorthwith your Azure region - Replace
gpt_4_1_deployment_namewith your actual model deployment name - Replace
Simple_Agentwith your agent name
Where it goes
Save as AGENTS.md in your repository root. Read by Codex, Cursor and other agents that follow the AGENTS.md convention.
Worth borrowing
- Phase-by-phase implementation order with estimates for each step
- Interactive Azure CLI script with CAF naming convention and idempotent checks
- Explicit keep/remove lists for Makefile and pyproject.toml to avoid accidental deletions
Related Documents
Browser-only development
Guides AI assistants on an Electron + React + TypeScript desktop app for browsing and organizing AI-generated images locally.
Claude Agents β Reference & Recommendations
Catalogues 40+ Claude agents and marketing skills for building a cat adoption charity landing page, with a ready-to-paste prompt and backend API reference.
Golden DKG Prototype -- Master Plan
Defines an 8-phase implementation plan for a Rust prototype of the Golden non-interactive DKG protocol using BLS12-381 and tokio.
Swarms Examples Index
Lists 60+ example scripts for building single and multi-agent systems with the Swarms framework, organized by category and use case.