Documentation
¶
Index ¶
- type AgentError
- type AgentStep
- type LLMCall
- type LogTracer
- func (t *LogTracer) GetTraceID(ctx context.Context) string
- func (t *LogTracer) RecordAgentStep(ctx context.Context, step *AgentStep)
- func (t *LogTracer) RecordError(ctx context.Context, err *AgentError)
- func (t *LogTracer) RecordLLMCall(ctx context.Context, call *LLMCall)
- func (t *LogTracer) RecordToolCall(ctx context.Context, call *ToolCall)
- func (t *LogTracer) WithTrace(ctx context.Context) context.Context
- type LogTracerConfig
- type NoopTracer
- func (t *NoopTracer) GetTraceID(ctx context.Context) string
- func (t *NoopTracer) RecordAgentStep(ctx context.Context, step *AgentStep)
- func (t *NoopTracer) RecordError(ctx context.Context, err *AgentError)
- func (t *NoopTracer) RecordLLMCall(ctx context.Context, call *LLMCall)
- func (t *NoopTracer) RecordToolCall(ctx context.Context, call *ToolCall)
- func (t *NoopTracer) WithTrace(ctx context.Context) context.Context
- type ToolCall
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentError ¶
type AgentError struct {
TraceID string
AgentID string
ErrorType string
Message string
Metadata map[string]any
}
AgentError represents an error during agent execution.
type AgentStep ¶
type AgentStep struct {
TraceID string
AgentID string
StepName string
Metadata map[string]any
Duration time.Duration
Error error
}
AgentStep represents an agent execution step.
type LLMCall ¶
type LLMCall struct {
TraceID string
Model string
Prompt string
Response string
TokensUsed int
Duration time.Duration
Error error
}
LLMCall represents an LLM invocation.
type LogTracer ¶
type LogTracer struct {
// contains filtered or unexported fields
}
LogTracer is a tracer that logs to standard output using slog. It can be used for development and debugging.
func (*LogTracer) GetTraceID ¶
GetTraceID returns the trace ID from context.
func (*LogTracer) RecordAgentStep ¶
RecordAgentStep implements Tracer.
func (*LogTracer) RecordError ¶
func (t *LogTracer) RecordError(ctx context.Context, err *AgentError)
RecordError implements Tracer.
func (*LogTracer) RecordLLMCall ¶
RecordLLMCall implements Tracer.
func (*LogTracer) RecordToolCall ¶
RecordToolCall implements Tracer.
type LogTracerConfig ¶
LogTracerConfig holds configuration for LogTracer.
type NoopTracer ¶
type NoopTracer struct{}
NoopTracer is a lightweight tracer that manages trace IDs in context without performing any external recording. Use this when observability overhead should be minimal but trace ID propagation is still needed.
func (*NoopTracer) GetTraceID ¶
func (t *NoopTracer) GetTraceID(ctx context.Context) string
GetTraceID returns the trace ID from context if present.
func (*NoopTracer) RecordAgentStep ¶
func (t *NoopTracer) RecordAgentStep(ctx context.Context, step *AgentStep)
RecordAgentStep implements Tracer. No-op: does not record.
func (*NoopTracer) RecordError ¶
func (t *NoopTracer) RecordError(ctx context.Context, err *AgentError)
RecordError implements Tracer. No-op: does not record.
func (*NoopTracer) RecordLLMCall ¶
func (t *NoopTracer) RecordLLMCall(ctx context.Context, call *LLMCall)
RecordLLMCall implements Tracer. No-op: does not record.
func (*NoopTracer) RecordToolCall ¶
func (t *NoopTracer) RecordToolCall(ctx context.Context, call *ToolCall)
RecordToolCall implements Tracer. No-op: does not record.
type ToolCall ¶
type ToolCall struct {
TraceID string
ToolName string
Input any
Output any
Duration time.Duration
Error error
}
ToolCall represents a tool execution.
type Tracer ¶
type Tracer interface {
// RecordLLMCall records an LLM call.
RecordLLMCall(ctx context.Context, call *LLMCall)
// RecordToolCall records a tool execution.
RecordToolCall(ctx context.Context, call *ToolCall)
// RecordAgentStep records an agent step.
RecordAgentStep(ctx context.Context, step *AgentStep)
// RecordError records an error.
RecordError(ctx context.Context, err *AgentError)
// GetTraceID returns the current trace ID.
GetTraceID(ctx context.Context) string
// WithTrace returns a new context with trace ID.
WithTrace(ctx context.Context) context.Context
}
Tracer defines the interface for observability tracking.
func NewLogTracer ¶
func NewLogTracer(cfg *LogTracerConfig) Tracer
NewLogTracer creates a new LogTracer.