monitoring

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppStats

type AppStats struct {
	Name        string  `json:"name"`
	Version     string  `json:"version"`
	Environment string  `json:"environment"`
	Uptime      int64   `json:"uptime"`       // in seconds
	MemoryUsage int64   `json:"memory_usage"` // in bytes
	CPUUsage    float64 `json:"cpu_usage"`    // percentage
	Requests    int64   `json:"requests"`
	Errors      int64   `json:"errors"`
}

AppStats represents application statistics

type CacheStats

type CacheStats struct {
	Driver      string  `json:"driver"`
	Connected   bool    `json:"connected"`
	HitCount    int64   `json:"hit_count"`
	MissCount   int64   `json:"miss_count"`
	HitRate     float64 `json:"hit_rate"`     // percentage
	MemoryUsage int64   `json:"memory_usage"` // in bytes
}

CacheStats represents cache statistics

type CronCollector

type CronCollector interface {
	GetTasks() ([]TaskInfo, error)
	GetExecutions(limit int) ([]ExecutionInfo, error)
	GetTaskExecutions(taskName string, limit int) ([]ExecutionInfo, error)
}

CronCollector interface for different scheduler drivers

type CronMonitor

type CronMonitor struct {
	// contains filtered or unexported fields
}

CronMonitor handles cron/scheduler monitoring

func NewCronMonitor

func NewCronMonitor() *CronMonitor

NewCronMonitor creates a new CronMonitor

func (*CronMonitor) GetCronStatsJSON

func (cm *CronMonitor) GetCronStatsJSON() ([]byte, error)

GetCronStatsJSON returns cron statistics as JSON

func (*CronMonitor) GetStats

func (cm *CronMonitor) GetStats() *CronStats

GetStats returns the current cron statistics

func (*CronMonitor) RegisterCollector

func (cm *CronMonitor) RegisterCollector(driver string, collector CronCollector)

RegisterCollector registers a cron collector for a specific driver

func (*CronMonitor) RegisterRoutes

func (cm *CronMonitor) RegisterRoutes(app *fiber.App)

RegisterRoutes registers monitoring routes

func (*CronMonitor) UpdateStats

func (cm *CronMonitor) UpdateStats() error

UpdateStats updates the cron statistics

type CronStats

type CronStats struct {
	Driver      string          `json:"driver"`
	Tasks       []TaskInfo      `json:"tasks"`
	Executions  []ExecutionInfo `json:"executions"`
	LastUpdated time.Time       `json:"last_updated"`
}

CronStats represents cron/scheduler statistics

type DatabaseStats

type DatabaseStats struct {
	Driver       string `json:"driver"`
	Connected    bool   `json:"connected"`
	ActiveConns  int    `json:"active_connections"`
	IdleConns    int    `json:"idle_connections"`
	MaxConns     int    `json:"max_connections"`
	QueryCount   int64  `json:"query_count"`
	SlowQueries  int64  `json:"slow_queries"`
	AvgQueryTime int    `json:"avg_query_time"` // in milliseconds
}

DatabaseStats represents database statistics

type ExecutionInfo

type ExecutionInfo struct {
	TaskName   string    `json:"task_name"`
	StartedAt  time.Time `json:"started_at"`
	FinishedAt time.Time `json:"finished_at,omitempty"`
	Duration   int       `json:"duration"` // in milliseconds
	Status     string    `json:"status"`   // running, completed, failed
	Error      string    `json:"error,omitempty"`
	Output     string    `json:"output,omitempty"`
}

ExecutionInfo represents information about a task execution

type FailedJobInfo

type FailedJobInfo struct {
	ID         string    `json:"id"`
	Job        string    `json:"job"`
	Queue      string    `json:"queue"`
	Error      string    `json:"error"`
	FailedAt   time.Time `json:"failed_at"`
	Retries    int       `json:"retries"`
	MaxRetries int       `json:"max_retries"`
}

FailedJobInfo represents information about a failed job

type QueueCollector

type QueueCollector interface {
	GetQueueStats() (map[string]QueueInfo, error)
	GetWorkers() ([]WorkerInfo, error)
	GetFailedJobs() ([]FailedJobInfo, error)
}

QueueCollector interface for different queue drivers

type QueueInfo

type QueueInfo struct {
	Name        string `json:"name"`
	Size        int    `json:"size"`
	Processing  int    `json:"processing"`
	Completed   int    `json:"completed"`
	Failed      int    `json:"failed"`
	Throughput  int    `json:"throughput"`    // jobs per minute
	AvgWaitTime int    `json:"avg_wait_time"` // in seconds
}

QueueInfo represents information about a specific queue

type QueueMonitor

type QueueMonitor struct {
	// contains filtered or unexported fields
}

QueueMonitor handles queue monitoring

func NewQueueMonitor

func NewQueueMonitor() *QueueMonitor

NewQueueMonitor creates a new QueueMonitor

func (*QueueMonitor) GetQueueStatsJSON

func (qm *QueueMonitor) GetQueueStatsJSON() ([]byte, error)

GetQueueStatsJSON returns queue statistics as JSON

func (*QueueMonitor) GetStats

func (qm *QueueMonitor) GetStats() *QueueStats

GetStats returns the current queue statistics

func (*QueueMonitor) RegisterCollector

func (qm *QueueMonitor) RegisterCollector(driver string, collector QueueCollector)

RegisterCollector registers a queue collector for a specific driver

func (*QueueMonitor) RegisterRoutes

func (qm *QueueMonitor) RegisterRoutes(app *fiber.App)

RegisterRoutes registers monitoring routes

func (*QueueMonitor) UpdateStats

func (qm *QueueMonitor) UpdateStats() error

UpdateStats updates the queue statistics

type QueueStats

type QueueStats struct {
	Driver      string               `json:"driver"`
	Queues      map[string]QueueInfo `json:"queues"`
	Workers     []WorkerInfo         `json:"workers"`
	FailedJobs  []FailedJobInfo      `json:"failed_jobs"`
	LastUpdated time.Time            `json:"last_updated"`
}

QueueStats represents queue statistics

type StorageStats

type StorageStats struct {
	Driver     string `json:"driver"`
	Connected  bool   `json:"connected"`
	TotalFiles int64  `json:"total_files"`
	TotalSize  int64  `json:"total_size"` // in bytes
	FreeSpace  int64  `json:"free_space"` // in bytes
}

StorageStats represents storage statistics

type SystemMonitor

type SystemMonitor struct {
	// contains filtered or unexported fields
}

SystemMonitor handles overall system monitoring

func NewSystemMonitor

func NewSystemMonitor() *SystemMonitor

NewSystemMonitor creates a new SystemMonitor

func (*SystemMonitor) GetStats

func (sm *SystemMonitor) GetStats() *SystemStats

GetStats returns the current system statistics

func (*SystemMonitor) GetSystemStatsJSON

func (sm *SystemMonitor) GetSystemStatsJSON() ([]byte, error)

GetSystemStatsJSON returns system statistics as JSON

func (*SystemMonitor) RegisterCollector

func (sm *SystemMonitor) RegisterCollector(component string, collector interface{})

RegisterCollector registers a collector for a specific component

func (*SystemMonitor) RegisterRoutes

func (sm *SystemMonitor) RegisterRoutes(app *fiber.App)

RegisterRoutes registers monitoring routes

func (*SystemMonitor) UpdateStats

func (sm *SystemMonitor) UpdateStats() error

UpdateStats updates the system statistics

type SystemStats

type SystemStats struct {
	App         AppStats      `json:"app"`
	Database    DatabaseStats `json:"database"`
	Queue       *QueueStats   `json:"queue,omitempty"`
	Cron        *CronStats    `json:"cron,omitempty"`
	Cache       CacheStats    `json:"cache"`
	Storage     StorageStats  `json:"storage"`
	LastUpdated time.Time     `json:"last_updated"`
}

SystemStats represents overall system statistics

type TaskInfo

type TaskInfo struct {
	Name         string    `json:"name"`
	Schedule     string    `json:"schedule"`
	Description  string    `json:"description"`
	Enabled      bool      `json:"enabled"`
	LastRun      time.Time `json:"last_run,omitempty"`
	NextRun      time.Time `json:"next_run,omitempty"`
	RunCount     int       `json:"run_count"`
	SuccessCount int       `json:"success_count"`
	FailureCount int       `json:"failure_count"`
	AvgDuration  int       `json:"avg_duration"` // in milliseconds
}

TaskInfo represents information about a scheduled task

type WorkerInfo

type WorkerInfo struct {
	ID         string    `json:"id"`
	Status     string    `json:"status"` // idle, working, stopped
	CurrentJob string    `json:"current_job,omitempty"`
	Processed  int       `json:"processed"`
	Failed     int       `json:"failed"`
	StartedAt  time.Time `json:"started_at"`
	LastJobAt  time.Time `json:"last_job_at,omitempty"`
}

WorkerInfo represents information about a worker

Jump to

Keyboard shortcuts

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