Table of Contents

Class JsonTraceExporter

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

Exports traces as JSON for analysis or debugging.

public sealed class JsonTraceExporter : ITraceExporter, IDisposable
Inheritance
JsonTraceExporter
Implements
Inherited Members

Examples

Persisting all spans of a session to a JSON file for later analysis:

using LMKit.Agents.Observability;

using var exporter = new JsonTraceExporter("trace.json") { AutoFlush = true }; var tracer = new InMemoryTracer();

using var executor = new TracingAgentExecutor(new AgentExecutor(), tracer); await executor.ExecuteAsync(agent, "Generate a daily summary.");

foreach (var span in tracer.Spans) { exporter.Export(span); }

Constructors

JsonTraceExporter(TextWriter)

Initializes a JSON exporter that writes to a TextWriter.

JsonTraceExporter(string)

Initializes a JSON exporter that writes to a file.

Properties

AutoFlush

Gets or sets whether to auto-flush after each span.

BufferedCount

Gets the number of spans currently buffered.

Methods

Dispose()

Disposes the exporter, flushing any remaining spans.

Export(AgentSpan)

Exports a completed span.

Flush()

Flushes any buffered spans.

GetJson()

Gets all buffered spans as a JSON string without clearing the buffer.

Share