Class CompositeTracer
- Namespace
- LMKit.Agents.Observability
- Assembly
- LM-Kit.NET.dll
A tracer that forwards to multiple underlying tracers.
Use this to send traces to multiple destinations simultaneously (e.g., console for debugging and OpenTelemetry for production monitoring).
public sealed class CompositeTracer : IAgentTracer
- Inheritance
-
CompositeTracer
- Implements
- Inherited Members
Examples
Forwarding to console + in-memory tracers at once:
using LMKit.Agents.Observability;
var memory = new InMemoryTracer();
IAgentTracer tracer = new CompositeTracer(new ConsoleTracer(), memory);
using var executor = new TracingAgentExecutor(new AgentExecutor(), tracer);
await executor.ExecuteAsync(agent, "Run the daily check.");
// Inspect spans collected by the in-memory tracer (console got the same data live).
var summary = memory.GetTraceSummary();
Remarks
Note: Span operations are forwarded to all tracers, but only the first tracer's span is returned. This means attributes set directly on returned spans only affect the first tracer. For full multi-tracer support, use the tracer's Log and RecordMetric methods.
Constructors
- CompositeTracer()
Initializes a new instance of the CompositeTracer class.
- CompositeTracer(params IAgentTracer[])
Initializes a composite tracer with the specified tracers.
Properties
- Tracers
Gets the underlying tracers.
Methods
- Add(IAgentTracer)
Adds a tracer to the composite.
- EndAllSpans(AgentSpan)
Ends all spans associated with the given primary span.
- 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.