Documentation
¶
Overview ¶
Package monitor provides health checks, metrics collection, and monitoring capabilities for applications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DatabaseChecker ¶
type DatabaseChecker struct {
// contains filtered or unexported fields
}
DatabaseChecker checks database connectivity
func NewDatabaseChecker ¶
func NewDatabaseChecker(name string, ping func(ctx context.Context) error) *DatabaseChecker
NewDatabaseChecker creates a new database checker
func (*DatabaseChecker) Check ¶
func (d *DatabaseChecker) Check(ctx context.Context) *HealthStatus
func (*DatabaseChecker) Name ¶
func (d *DatabaseChecker) Name() string
type DiskSpaceChecker ¶
type DiskSpaceChecker struct {
// contains filtered or unexported fields
}
DiskSpaceChecker checks available disk space
func NewDiskSpaceChecker ¶
func NewDiskSpaceChecker(path string, threshold float64) *DiskSpaceChecker
NewDiskSpaceChecker creates a new disk space checker
func (*DiskSpaceChecker) Check ¶
func (d *DiskSpaceChecker) Check(ctx context.Context) *HealthStatus
func (*DiskSpaceChecker) Name ¶
func (d *DiskSpaceChecker) Name() string
type HTTPChecker ¶
type HTTPChecker struct {
// contains filtered or unexported fields
}
HTTPChecker checks HTTP endpoint health
func NewHTTPChecker ¶
func NewHTTPChecker(name, url string) *HTTPChecker
NewHTTPChecker creates a new HTTP checker
func (*HTTPChecker) Check ¶
func (h *HTTPChecker) Check(ctx context.Context) *HealthStatus
func (*HTTPChecker) Name ¶
func (h *HTTPChecker) Name() string
type HealthChecker ¶
type HealthChecker interface {
// Check performs a health check
Check(ctx context.Context) *HealthStatus
// Name returns the checker name
Name() string
}
HealthChecker defines the health check interface
type HealthReport ¶
type HealthReport struct {
Status Status `json:"status"`
Checks map[string]*HealthStatus `json:"checks"`
System *SystemMetrics `json:"system"`
Timestamp time.Time `json:"timestamp"`
}
HealthReport represents the overall health report
type HealthStatus ¶
type HealthStatus struct {
Status Status `json:"status"`
Message string `json:"message,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
LastChecked time.Time `json:"last_checked"`
Duration time.Duration `json:"duration_ms"`
}
HealthStatus represents the health status of a component
type MemoryMetrics ¶
type MemoryMetrics struct {
Alloc uint64 `json:"alloc_bytes"`
TotalAlloc uint64 `json:"total_alloc_bytes"`
Sys uint64 `json:"sys_bytes"`
NumGC uint32 `json:"num_gc"`
}
MemoryMetrics represents memory metrics
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics tracks application metrics
func (*Metrics) RecordHealthCheck ¶
RecordHealthCheck records a health check result
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor manages health checks and metrics
func NewMonitor ¶
NewMonitor creates a new monitor
func (*Monitor) AddChecker ¶
func (m *Monitor) AddChecker(checker HealthChecker)
AddChecker adds a health checker
func (*Monitor) CheckHealth ¶
func (m *Monitor) CheckHealth(ctx context.Context) *HealthReport
CheckHealth performs an immediate health check
func (*Monitor) GetHealth ¶
func (m *Monitor) GetHealth() *HealthReport
GetHealth returns the overall health status
func (*Monitor) RemoveChecker ¶
RemoveChecker removes a health checker
type PingChecker ¶
type PingChecker struct{}
PingChecker checks basic connectivity
func (*PingChecker) Check ¶
func (p *PingChecker) Check(ctx context.Context) *HealthStatus
func (*PingChecker) Name ¶
func (p *PingChecker) Name() string
type SystemMetrics ¶
type SystemMetrics struct {
Memory MemoryMetrics `json:"memory"`
Goroutines int `json:"goroutines"`
CPUs int `json:"cpus"`
Uptime time.Duration `json:"uptime_seconds"`
}
SystemMetrics represents system-level metrics