monitoring

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllMetrics

func GetAllMetrics() map[string]*ServiceMetrics

GetAllMetrics returns all metrics from global dashboard

func RegisterRoutes

func RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers routes using global handler

func RegisterService

func RegisterService(name, serviceType string)

RegisterService registers a service in global dashboard

func UpdateCircuitBreakerStats

func UpdateCircuitBreakerStats(name string, stats CircuitBreakerStats)

UpdateCircuitBreakerStats updates circuit breaker stats in global dashboard

func UpdatePoolStats

func UpdatePoolStats(name string, stats PoolStats)

UpdatePoolStats updates pool stats in global dashboard

func UpdateServiceMetrics

func UpdateServiceMetrics(name string, m *metrics.Metrics)

UpdateServiceMetrics updates service metrics in global dashboard

Types

type CircuitBreakerStats

type CircuitBreakerStats struct {
	State                string  `json:"state"`
	Requests             uint32  `json:"requests"`
	TotalSuccesses       uint32  `json:"total_successes"`
	TotalFailures        uint32  `json:"total_failures"`
	ConsecutiveSuccesses uint32  `json:"consecutive_successes"`
	ConsecutiveFailures  uint32  `json:"consecutive_failures"`
	SuccessRate          float64 `json:"success_rate"` // percentage
}

CircuitBreakerStats represents circuit breaker statistics

type Dashboard

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

Dashboard aggregates metrics from all services

func NewDashboard

func NewDashboard() *Dashboard

NewDashboard creates a new monitoring dashboard

func (*Dashboard) GetAllMetrics

func (d *Dashboard) GetAllMetrics() map[string]*ServiceMetrics

GetAllMetrics returns metrics for all services

func (*Dashboard) GetDashboardSnapshot

func (d *Dashboard) GetDashboardSnapshot() DashboardSnapshot

GetDashboardSnapshot returns a complete dashboard snapshot

func (*Dashboard) GetServiceMetrics

func (d *Dashboard) GetServiceMetrics(name string) (*ServiceMetrics, bool)

GetServiceMetrics returns metrics for a specific service

func (*Dashboard) GetServicesByType

func (d *Dashboard) GetServicesByType(serviceType string) []*ServiceMetrics

GetServicesByType returns all services of a specific type

func (*Dashboard) GetUnhealthyServices

func (d *Dashboard) GetUnhealthyServices() []*ServiceMetrics

GetUnhealthyServices returns all unhealthy services

func (*Dashboard) HealthCheckAll

func (d *Dashboard) HealthCheckAll(ctx context.Context) map[string]health.CheckResult

HealthCheckAll performs health checks on all registered services

func (*Dashboard) RegisterService

func (d *Dashboard) RegisterService(name, serviceType string)

RegisterService registers a service for monitoring

func (*Dashboard) StartPeriodicUpdate

func (d *Dashboard) StartPeriodicUpdate(interval time.Duration) chan struct{}

StartPeriodicUpdate starts periodic metrics update

func (*Dashboard) UpdateCircuitBreakerStats

func (d *Dashboard) UpdateCircuitBreakerStats(name string, stats CircuitBreakerStats)

UpdateCircuitBreakerStats updates circuit breaker stats for a service

func (*Dashboard) UpdatePoolStats

func (d *Dashboard) UpdatePoolStats(name string, stats PoolStats)

UpdatePoolStats updates pool statistics for a service

func (*Dashboard) UpdateServiceMetrics

func (d *Dashboard) UpdateServiceMetrics(name string, m *metrics.Metrics)

UpdateServiceMetrics updates metrics for a service

type DashboardSnapshot

type DashboardSnapshot struct {
	Timestamp     time.Time                  `json:"timestamp"`
	OverallStatus health.Status              `json:"overall_status"`
	Services      map[string]*ServiceMetrics `json:"services"`
	Summary       DashboardSummary           `json:"summary"`
}

DashboardSnapshot represents a point-in-time dashboard snapshot

func GetDashboardSnapshot

func GetDashboardSnapshot() DashboardSnapshot

GetDashboardSnapshot returns snapshot from global dashboard

type DashboardSummary

type DashboardSummary struct {
	TotalServices      int     `json:"total_services"`
	HealthyServices    int     `json:"healthy_services"`
	DegradedServices   int     `json:"degraded_services"`
	UnhealthyServices  int     `json:"unhealthy_services"`
	TotalConnections   int64   `json:"total_connections"`
	TotalOperations    int64   `json:"total_operations"`
	TotalErrors        int64   `json:"total_errors"`
	AverageLatencyMs   int64   `json:"average_latency_ms"`
	OverallSuccessRate float64 `json:"overall_success_rate"`
}

DashboardSummary provides aggregated statistics

type Handler

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

Handler provides HTTP handlers for monitoring endpoints

func GetHandler

func GetHandler() *Handler

GetHandler returns global handler

func InitHandler

func InitHandler() *Handler

InitHandler initializes global handler

func NewHandler

func NewHandler(dashboard *Dashboard) *Handler

NewHandler creates a new monitoring handler

func (*Handler) HandleAllMetrics

func (h *Handler) HandleAllMetrics(w http.ResponseWriter, r *http.Request)

HandleAllMetrics returns metrics for all services

func (*Handler) HandleDashboard

func (h *Handler) HandleDashboard(w http.ResponseWriter, r *http.Request)

HandleDashboard returns dashboard snapshot

func (*Handler) HandleHealth

func (h *Handler) HandleHealth(w http.ResponseWriter, r *http.Request)

HandleHealth returns overall health status

func (*Handler) HandleLiveness

func (h *Handler) HandleLiveness(w http.ResponseWriter, r *http.Request)

HandleLiveness returns liveness status (basic ping)

func (*Handler) HandleReadiness

func (h *Handler) HandleReadiness(w http.ResponseWriter, r *http.Request)

HandleReadiness returns readiness status (quick check)

func (*Handler) HandleServiceMetrics

func (h *Handler) HandleServiceMetrics(w http.ResponseWriter, r *http.Request)

HandleServiceMetrics returns metrics for specific service

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers monitoring routes with HTTP mux

type PoolStats

type PoolStats struct {
	OpenConnections int     `json:"open_connections"`
	IdleConnections int     `json:"idle_connections"`
	WaitingRequests int     `json:"waiting_requests"`
	MaxOpenConns    int     `json:"max_open_conns"`
	MaxIdleConns    int     `json:"max_idle_conns"`
	Utilization     float64 `json:"utilization"` // percentage
}

PoolStats represents connection pool statistics

type ServiceMetrics

type ServiceMetrics struct {
	Name           string                  `json:"name"`
	Type           string                  `json:"type"` // redis, mongodb, mysql, sqlite, http, grpc, etc.
	Status         health.Status           `json:"status"`
	Metrics        metrics.MetricsSnapshot `json:"metrics"`
	PoolStats      *PoolStats              `json:"pool_stats,omitempty"`
	CircuitBreaker *CircuitBreakerStats    `json:"circuit_breaker,omitempty"`
	LastUpdated    time.Time               `json:"last_updated"`
}

ServiceMetrics represents metrics for a specific service

func GetServiceMetrics

func GetServiceMetrics(name string) (*ServiceMetrics, bool)

GetServiceMetrics returns service metrics from global dashboard

Jump to

Keyboard shortcuts

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