👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/agents/agent_telemetry_with_activity_source
Agent Telemetry for C# .NET Applications
🎯 Purpose of the Demo
Demonstrates the OpenTelemetry-compatible distributed-trace surface introduced in LM-Kit.NET 2026.5.2 via LMKit.Agents.Observability.AgentDiagnostics. Every orchestration run, every per-agent invocation, and every delegation surface as a standard System.Diagnostics.Activity span with stable, OpenTelemetry-style tag names.
👥 Who Should Use This Demo
C# / .NET developers who run agents in production and need cross-process trace correlation, latency SLOs, and failure-rate alerts, without instrumenting any orchestration code by hand.
🚀 What Problem It Solves
Previously, observing what an agent runtime did required wiring the in-process IAgentTracer interface and exporting the trace yourself. With the new ActivitySource, the runtime emits standard distributed-trace spans that plug directly into OpenTelemetry, Jaeger, Tempo, Datadog, Application Insights, or any ActivityListener-based exporter, no custom adapter code.
💻 Demo Application Overview
A two-stage research+write pipeline runs while an ActivityListener subscribed to AgentDiagnostics.SourceName ("LMKit.Agents") prints each span's start, stop, duration, status, and tags to the console. In production you would swap the listener for Sdk.CreateTracerProviderBuilder().AddSource(AgentDiagnostics.SourceName).AddOtlpExporter().Build().
✨ Key Features
- Standard
ActivitySourcenamedLMKit.Agents, with constants exposed viaAgentDiagnostics.SourceNameandAgentDiagnostics.Tag*. - Three span kinds:
orchestration.execute,agent.execute,agent.delegate. Covers every orchestrator and every delegation. - Stable OpenTelemetry-style tags (
agent.name,orchestrator.name,orchestration.step,agent.planning_strategy,agent.status,agent.inference_count,delegation.from,delegation.to). - Spans end with
ActivityStatusCode.OkorErrorso failure-rate alerts work without parsing tags. - Independent of and complementary to the existing
IAgentTracersystem.
Example Output
[start] orchestration.execute [orchestrator.name=Pipeline]
[start] agent.execute [agent.name=Researcher, orchestrator.name=Pipeline, orchestration.step=1, agent.planning_strategy=None]
[stop ] agent.execute 312 ms status=Ok [agent.name=Researcher, ..., agent.status=Completed, agent.inference_count=1]
[start] agent.execute [agent.name=Writer, ..., orchestration.step=2, agent.planning_strategy=None]
[stop ] agent.execute 245 ms status=Ok [agent.name=Writer, ..., agent.status=Completed, agent.inference_count=1]
[stop ] orchestration.execute 558 ms status=Ok [orchestrator.name=Pipeline]
⚙️ Getting Started
Prerequisites: .NET 8.0+, ~6 GB VRAM (CPU-only also works). Default model qwen3.5:9b downloads on first run.
Run:
cd demos/console_net/agents/agent_telemetry_with_activity_source
dotnet run -c Release
🚀 Extend the Demo
- Swap the demo's
ActivityListenerfor an OpenTelemetry tracer provider withAddOtlpExporter()and watch the same spans land in Jaeger, Tempo, or Datadog. - Combine with the Graph Orchestration Showcase to see traces nested across
Sequential,Parallel, andConditionalgraph shapes. - Add a
SupervisorOrchestratorand observeagent.delegatespans withdelegation.fromanddelegation.totags.