analytics

package
v0.3.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package analytics provides metrics tracking and visualization

Index

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

func NewManager(cfg Config) (*Manager, error)

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) EndTask

func (m *Manager) EndTask(taskID string, status string, errorMsg string)

EndTask completes tracking a task execution

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

func (m *Manager) IncrementCounter(name string, value float64, labels map[string]string)

IncrementCounter increments a counter metric

func (*Manager) IncrementTaskLLMCalls

func (m *Manager) IncrementTaskLLMCalls(taskID string)

IncrementTaskLLMCalls increments the LLM call count for a task

func (*Manager) LoadFromFile

func (m *Manager) LoadFromFile(path string) error

LoadFromFile loads metrics from a JSON file

func (*Manager) RecordHistogram

func (m *Manager) RecordHistogram(name string, value float64, labels map[string]string)

RecordHistogram records a histogram metric

func (*Manager) RecordMetric

func (m *Manager) RecordMetric(metric *Metric)

RecordMetric records a single metric

func (*Manager) SaveToFile

func (m *Manager) SaveToFile(path string) error

SaveToFile saves metrics to a JSON file

func (*Manager) SetGauge

func (m *Manager) SetGauge(name string, value float64, labels map[string]string)

SetGauge sets a gauge metric

func (*Manager) SetLogger

func (m *Manager) SetLogger(logger *log.Logger)

SetLogger sets the logger for the manager

func (*Manager) StartTask

func (m *Manager) StartTask(taskID, title, agentType, projectID string)

StartTask starts tracking a task execution

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context) error

Stop stops the analytics manager

func (*Manager) UpdateTaskFiles

func (m *Manager) UpdateTaskFiles(taskID string, created, modified, deleted int)

UpdateTaskFiles updates file operation counts for a task

func (*Manager) UpdateTaskTokens

func (m *Manager) UpdateTaskTokens(taskID string, tokenCount int)

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

type TimeSeriesData

type TimeSeriesData struct {
	Timestamp int64             `json:"timestamp"`
	Value     float64           `json:"value"`
	Labels    map[string]string `json:"labels,omitempty"`
}

TimeSeriesData represents a time series data point

Jump to

Keyboard shortcuts

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