Table of Contents

Interface IAgentTracer

Namespace
LMKit.Agents.Observability
Assembly
LM-Kit.NET.dll

Interface for tracing agent operations.

Implement this interface to integrate with your preferred observability system (OpenTelemetry, Application Insights, custom logging, etc.).

public interface IAgentTracer

Examples

Wiring an in-memory tracer to an executor and reading the recorded spans:

using LMKit.Model;
using LMKit.Agents;
using LMKit.Agents.Observability;

using var model = LM.LoadFromModelID("qwen3:8b"); var agent = Agent.CreateBuilder(model).WithPersona("Assistant").Build();

IAgentTracer tracer = new InMemoryTracer(); using var executor = new TracingAgentExecutor(new AgentExecutor(), tracer); await executor.ExecuteAsync(agent, "Summarize today's incidents.");

var summary = ((InMemoryTracer)tracer).GetTraceSummary(); Console.WriteLine($"{summary.TotalSpans} spans, {summary.TotalDuration.TotalMilliseconds:F0} ms total.");

Methods

Log(LogLevel, string, AgentSpan)

Records a log message associated with a span.

RecordMetric(string, double, Dictionary<string, string>)

Records a metric value.

StartAgentSpan(Agent, string, AgentSpan)

Starts a new span for an agent execution.

StartDelegationSpan(string, string, AgentSpan)

Starts a new span for a delegation operation.

StartInferenceSpan(string, AgentSpan)

Starts a new span for a model inference call.

StartOrchestrationSpan(string, string)

Starts a new span for an orchestration operation.

StartPlanningSpan(PlanningStrategy, AgentSpan)

Starts a new span for a planning operation.

StartToolSpan(string, string, AgentSpan)

Starts a new span for a tool invocation.

Share