Documentation
¶
Overview ¶
Package analytics provides metrics tracking and visualization
Index ¶
- type AggregatedMetrics
- type Config
- type Manager
- func (m *Manager) AggregateMetrics(startTime, endTime int64) *AggregatedMetrics
- func (m *Manager) EndTask(taskID string, status string, errorMsg string)
- func (m *Manager) GetAllTaskMetrics() []*TaskMetrics
- func (m *Manager) GetMetrics(name string, labels map[string]string, startTime, endTime int64) []*Metric
- func (m *Manager) GetTaskMetrics(taskID string) *TaskMetrics
- func (m *Manager) GetTimeSeries(name string, labels map[string]string, startTime, endTime int64, ...) []*TimeSeriesData
- func (m *Manager) IncrementCounter(name string, value float64, labels map[string]string)
- func (m *Manager) IncrementTaskLLMCalls(taskID string)
- func (m *Manager) LoadFromFile(path string) error
- func (m *Manager) RecordHistogram(name string, value float64, labels map[string]string)
- func (m *Manager) RecordMetric(metric *Metric)
- func (m *Manager) SaveToFile(path string) error
- func (m *Manager) SetGauge(name string, value float64, labels map[string]string)
- func (m *Manager) SetLogger(logger *log.Logger)
- func (m *Manager) StartTask(taskID, title, agentType, projectID string)
- func (m *Manager) Stop(ctx context.Context) error
- func (m *Manager) UpdateTaskFiles(taskID string, created, modified, deleted int)
- func (m *Manager) UpdateTaskTokens(taskID string, tokenCount int)
- type Metric
- type MetricType
- type TaskMetrics
- type TimeSeriesData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregatedMetrics ¶
type AggregatedMetrics struct {
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
TotalTasks int `json:"total_tasks"`
SuccessTasks int `json:"success_tasks"`
FailedTasks int `json:"failed_tasks"`
AvgDuration float64 `json:"avg_duration_ms"`
TotalTokens int `json:"total_tokens"`
TotalLLMCalls int `json:"total_llm_calls"`
ByAgentType map[string]int `json:"by_agent_type"`
ByStatus map[string]int `json:"by_status"`
}
AggregatedMetrics represents aggregated metrics over a time period
type Config ¶
type Config struct {
ConfigPath string
Logger *log.Logger
MaxMetrics int // Maximum metrics to keep in memory
FlushInterval time.Duration // How often to flush metrics to disk
}
Config holds manager configuration
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages analytics and metrics collection
func NewManager ¶
NewManager creates a new analytics manager
func (*Manager) AggregateMetrics ¶
func (m *Manager) AggregateMetrics(startTime, endTime int64) *AggregatedMetrics
AggregateMetrics aggregates metrics over a time period
func (*Manager) GetAllTaskMetrics ¶
func (m *Manager) GetAllTaskMetrics() []*TaskMetrics
GetAllTaskMetrics retrieves all task metrics
func (*Manager) GetMetrics ¶
func (m *Manager) GetMetrics(name string, labels map[string]string, startTime, endTime int64) []*Metric
GetMetrics retrieves metrics matching filters
func (*Manager) GetTaskMetrics ¶
func (m *Manager) GetTaskMetrics(taskID string) *TaskMetrics
GetTaskMetrics retrieves task metrics
func (*Manager) GetTimeSeries ¶
func (m *Manager) GetTimeSeries(name string, labels map[string]string, startTime, endTime int64, interval time.Duration) []*TimeSeriesData
GetTimeSeries retrieves time series data for a metric
func (*Manager) IncrementCounter ¶
IncrementCounter increments a counter metric
func (*Manager) IncrementTaskLLMCalls ¶
IncrementTaskLLMCalls increments the LLM call count for a task
func (*Manager) LoadFromFile ¶
LoadFromFile loads metrics from a JSON file
func (*Manager) RecordHistogram ¶
RecordHistogram records a histogram metric
func (*Manager) RecordMetric ¶
RecordMetric records a single metric
func (*Manager) SaveToFile ¶
SaveToFile saves metrics to a JSON file
func (*Manager) UpdateTaskFiles ¶
UpdateTaskFiles updates file operation counts for a task
func (*Manager) UpdateTaskTokens ¶
UpdateTaskTokens updates token usage for a task
type Metric ¶
type Metric struct {
Name string `json:"name"`
Type MetricType `json:"type"`
Value float64 `json:"value"`
Timestamp int64 `json:"timestamp"`
Labels map[string]string `json:"labels,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Metric represents a single metric data point
type MetricType ¶
type MetricType string
MetricType defines the type of metric
const ( MetricTypeCounter MetricType = "counter" MetricTypeGauge MetricType = "gauge" MetricTypeHistogram MetricType = "histogram" MetricTypeSummary MetricType = "summary" )
type TaskMetrics ¶
type TaskMetrics struct {
TaskID string `json:"task_id"`
Title string `json:"title"`
AgentType string `json:"agent_type"`
ProjectID string `json:"project_id"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time,omitempty"`
Duration int64 `json:"duration_ms"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
TokenCount int `json:"token_count"`
LLMCalls int `json:"llm_calls"`
FilesCreated int `json:"files_created"`
FilesModified int `json:"files_modified"`
FilesDeleted int `json:"files_deleted"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
TaskMetrics tracks metrics for a specific task execution