Tutorials ASP.NET Core with Agentic AI Tutorial
AI Tracing — Complete Guide
AI Tracing — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of ASP.NET Core with Agentic AI Tutorial on Toolliyo Academy.
On this page
ASP.NET Core with Agentic AI Tutorial · Lesson 58 of 100
AI Tracing
AI basics ✓ → Agents
Agents · 2 — Build · ~10 min · Module 6: AI Security and Observability
What is this?
AI tracing follows one request across HTTP, agent, tool, embedding, and vector calls with shared trace IDs. AgentNest uses OpenTelemetry ActivitySource for distributed traces.
Why should you care?
Slow CRM answers need span breakdown — was latency embedding, Pinecone, or GPT?
See it live — copy this example
Paste into an ASP.NET Core 8+ / AgentNest project, then run with dotnet run (set your API keys in user-secrets).
// AgentNest.Telemetry/AgentTelemetry.cs
public sealed class AgentTelemetry
{
static readonly ActivitySource Source = new("AgentNest.Agents");
public Activity Start(string agentName) =>
Source.StartActivity(agentName, ActivityKind.Internal);
}
// In RagPipeline
using var span = telemetry.Start("rag.ask");
span?.SetTag("tenant.id", tenantId);
span?.SetTag("rag.topk", topK);
What happened?
- ActivitySource creates spans exported to Azure Monitor Application Insights.
- Tags attach tenant and RAG parameters for trace search.
Practice next
- Add OpenTelemetry.AspNetCore and Azure Monitor exporter.
- Instrument AgentBase, RagPipeline, and kernel InvokeAsync.
- Propagate trace context to Service Bus messages.
- Add span events on each tool invocation with function name.
- Sample traces at 10% for high-volume CRM tenants.
Remember
OpenTelemetry traces tie HTTP to agent, RAG, and tool spans. Tag spans with tenant and agent metadata. Export to Application Insights for AgentNest ops.
Slow RAG investigation
ERP copilot p95 jumps from 2s to 9s.
Outcome: Trace shows Milvus search span grew — HNSW index rebuild fixed it.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!