observability

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

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

func (t *LogTracer) GetTraceID(ctx context.Context) string

GetTraceID returns the trace ID from context.

func (*LogTracer) RecordAgentStep

func (t *LogTracer) RecordAgentStep(ctx context.Context, step *AgentStep)

RecordAgentStep implements Tracer.

func (*LogTracer) RecordError

func (t *LogTracer) RecordError(ctx context.Context, err *AgentError)

RecordError implements Tracer.

func (*LogTracer) RecordLLMCall

func (t *LogTracer) RecordLLMCall(ctx context.Context, call *LLMCall)

RecordLLMCall implements Tracer.

func (*LogTracer) RecordToolCall

func (t *LogTracer) RecordToolCall(ctx context.Context, call *ToolCall)

RecordToolCall implements Tracer.

func (*LogTracer) WithTrace

func (t *LogTracer) WithTrace(ctx context.Context) context.Context

WithTrace returns a new context with a new trace ID.

type LogTracerConfig

type LogTracerConfig struct {
	Logger *slog.Logger
}

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.

func (*NoopTracer) WithTrace

func (t *NoopTracer) WithTrace(ctx context.Context) context.Context

WithTrace returns a new context with a generated trace ID.

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.

func NewNoopTracer

func NewNoopTracer() Tracer

NewNoopTracer creates a new NoopTracer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL