Documentation
¶
Overview ¶
Package monitoring provides logging and monitoring capabilities for agent execution.
This includes token usage tracking, timing information, structured logging, and execution monitoring for debugging and observability.
Index ¶
- Constants
- func SetDefaultLogLevel(level LogLevel)
- type AgentLogger
- func (al *AgentLogger) Debug(message string, args ...interface{})
- func (al *AgentLogger) Error(message string, args ...interface{})
- func (al *AgentLogger) GetLevel() LogLevel
- func (al *AgentLogger) Info(message string, args ...interface{})
- func (al *AgentLogger) LogStep(stepNumber int, stepType string, content string)
- func (al *AgentLogger) LogTiming(operation string, timing *Timing)
- func (al *AgentLogger) LogTokenUsage(usage *TokenUsage)
- func (al *AgentLogger) LogToolCall(toolName string, args map[string]interface{})
- func (al *AgentLogger) LogToolResult(toolName string, result interface{}, err error)
- func (al *AgentLogger) SetLevel(level LogLevel)
- func (al *AgentLogger) SetOutput(w io.Writer)
- func (al *AgentLogger) SetPrefix(prefix string)
- func (al *AgentLogger) SetTimestamps(timestamps bool)
- func (al *AgentLogger) SetUseColors(useColors bool)
- type LogLevel
- type Monitor
- func (m *Monitor) AddTokenUsage(usage *TokenUsage)
- func (m *Monitor) CreateChildLogger(prefix string) *AgentLogger
- func (m *Monitor) EndStep()
- func (m *Monitor) GetAverageStepDuration() time.Duration
- func (m *Monitor) GetLogger() *AgentLogger
- func (m *Monitor) GetStepDurations() []time.Duration
- func (m *Monitor) GetTotalDuration() time.Duration
- func (m *Monitor) GetTotalTokenUsage() *TokenUsage
- func (m *Monitor) IsEnabled() bool
- func (m *Monitor) LogSummary()
- func (m *Monitor) LogToolCall(toolName string, args map[string]interface{})
- func (m *Monitor) LogToolResult(toolName string, result interface{}, err error)
- func (m *Monitor) Reset()
- func (m *Monitor) SetEnabled(enabled bool)
- func (m *Monitor) StartStep(stepNumber int, stepType string)
- type Timing
- type TokenUsage
Constants ¶
const ( ResetColor = "\033[0m" RedColor = "\033[31m" GreenColor = "\033[32m" YellowColor = "\033[33m" BlueColor = "\033[34m" PurpleColor = "\033[35m" CyanColor = "\033[36m" WhiteColor = "\033[37m" // HEX color constants YELLOW_HEX = "#FFD700" )
Color constants for rich output
Variables ¶
This section is empty.
Functions ¶
func SetDefaultLogLevel ¶
func SetDefaultLogLevel(level LogLevel)
SetDefaultLogLevel sets the default log level for the package
Types ¶
type AgentLogger ¶
type AgentLogger struct {
// contains filtered or unexported fields
}
AgentLogger provides structured logging for agent operations
func GetDefaultLogger ¶
func GetDefaultLogger() *AgentLogger
GetDefaultLogger returns the default logger instance
func NewAgentLogger ¶
func NewAgentLogger(level LogLevel) *AgentLogger
NewAgentLogger creates a new agent logger
func (*AgentLogger) Debug ¶
func (al *AgentLogger) Debug(message string, args ...interface{})
Debug logs a debug message
func (*AgentLogger) Error ¶
func (al *AgentLogger) Error(message string, args ...interface{})
Error logs an error message
func (*AgentLogger) GetLevel ¶
func (al *AgentLogger) GetLevel() LogLevel
GetLevel returns the current logging level
func (*AgentLogger) Info ¶
func (al *AgentLogger) Info(message string, args ...interface{})
Info logs an info message
func (*AgentLogger) LogStep ¶
func (al *AgentLogger) LogStep(stepNumber int, stepType string, content string)
LogStep logs a step execution with formatted output
func (*AgentLogger) LogTiming ¶
func (al *AgentLogger) LogTiming(operation string, timing *Timing)
LogTiming logs timing information
func (*AgentLogger) LogTokenUsage ¶
func (al *AgentLogger) LogTokenUsage(usage *TokenUsage)
LogTokenUsage logs token usage information
func (*AgentLogger) LogToolCall ¶
func (al *AgentLogger) LogToolCall(toolName string, args map[string]interface{})
LogToolCall logs a tool call
func (*AgentLogger) LogToolResult ¶
func (al *AgentLogger) LogToolResult(toolName string, result interface{}, err error)
LogToolResult logs a tool result
func (*AgentLogger) SetLevel ¶
func (al *AgentLogger) SetLevel(level LogLevel)
SetLevel sets the logging level
func (*AgentLogger) SetOutput ¶
func (al *AgentLogger) SetOutput(w io.Writer)
SetOutput sets the output writer for the logger
func (*AgentLogger) SetPrefix ¶
func (al *AgentLogger) SetPrefix(prefix string)
SetPrefix sets a prefix for all log messages
func (*AgentLogger) SetTimestamps ¶
func (al *AgentLogger) SetTimestamps(timestamps bool)
SetTimestamps enables or disables timestamps in log messages
func (*AgentLogger) SetUseColors ¶
func (al *AgentLogger) SetUseColors(useColors bool)
SetUseColors enables or disables colored output
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor provides comprehensive monitoring for agent execution
func NewMonitor ¶
func NewMonitor(logger *AgentLogger) *Monitor
NewMonitor creates a new monitor instance
func (*Monitor) AddTokenUsage ¶
func (m *Monitor) AddTokenUsage(usage *TokenUsage)
AddTokenUsage adds token usage to the total count
func (*Monitor) CreateChildLogger ¶
func (m *Monitor) CreateChildLogger(prefix string) *AgentLogger
CreateChildLogger creates a child logger with a prefix
func (*Monitor) GetAverageStepDuration ¶
GetAverageStepDuration returns the average step duration
func (*Monitor) GetLogger ¶
func (m *Monitor) GetLogger() *AgentLogger
GetLogger returns the logger instance
func (*Monitor) GetStepDurations ¶
GetStepDurations returns all step durations
func (*Monitor) GetTotalDuration ¶
GetTotalDuration returns the total execution duration
func (*Monitor) GetTotalTokenUsage ¶
func (m *Monitor) GetTotalTokenUsage() *TokenUsage
GetTotalTokenUsage returns the total token usage
func (*Monitor) LogSummary ¶
func (m *Monitor) LogSummary()
LogSummary logs a summary of the monitoring session
func (*Monitor) LogToolCall ¶
LogToolCall logs a tool call
func (*Monitor) LogToolResult ¶
LogToolResult logs a tool result
func (*Monitor) SetEnabled ¶
SetEnabled enables or disables monitoring
type Timing ¶
type Timing struct {
StartTime time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time,omitempty"`
Duration *time.Duration `json:"duration,omitempty"`
}
Timing represents timing information for operations
func NewTiming ¶
func NewTiming() *Timing
NewTiming creates a new timing instance with start time set to now
func (*Timing) GetDuration ¶
GetDuration returns the duration, calculating it if not already done
type TokenUsage ¶
type TokenUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
TotalTokens int `json:"total_tokens"`
}
TokenUsage represents token usage statistics
func NewTokenUsage ¶
func NewTokenUsage(inputTokens, outputTokens int) *TokenUsage
NewTokenUsage creates a new TokenUsage instance
func (*TokenUsage) Add ¶
func (tu *TokenUsage) Add(other *TokenUsage)
Add combines this token usage with another
func (*TokenUsage) String ¶
func (tu *TokenUsage) String() string
String returns a string representation of token usage