Documentation
¶
Index ¶
- func NewExtension(opts ...ConfigOption) forge.Extension
- type Client
- type CollectorInfo
- type Config
- type ConfigOption
- func WithAuth(enabled bool) ConfigOption
- func WithBasePath(path string) ConfigOption
- func WithConfig(config Config) ConfigOption
- func WithExport(enabled bool) ConfigOption
- func WithHistoryDuration(duration time.Duration) ConfigOption
- func WithMaxDataPoints(max int) ConfigOption
- func WithPort(port int) ConfigOption
- func WithRealtime(enabled bool) ConfigOption
- func WithRefreshInterval(interval time.Duration) ConfigOption
- func WithRequireConfig(required bool) ConfigOption
- func WithTheme(theme string) ConfigOption
- func WithTitle(title string) ConfigOption
- type DashboardServer
- type DashboardSnapshot
- type DataCollector
- func (dc *DataCollector) CollectHealth(ctx context.Context) *HealthData
- func (dc *DataCollector) CollectMetrics(ctx context.Context) *MetricsData
- func (dc *DataCollector) CollectMetricsReport(ctx context.Context) *MetricsReport
- func (dc *DataCollector) CollectOverview(ctx context.Context) *OverviewData
- func (dc *DataCollector) CollectServiceDetail(ctx context.Context, serviceName string) *ServiceDetail
- func (dc *DataCollector) CollectServices(ctx context.Context) []ServiceInfo
- func (dc *DataCollector) Start(ctx context.Context, interval time.Duration)
- func (dc *DataCollector) Stop()
- type DataHistory
- func (dh *DataHistory) AddHealth(snapshot HealthSnapshot)
- func (dh *DataHistory) AddMetrics(snapshot MetricsSnapshot)
- func (dh *DataHistory) AddOverview(snapshot OverviewSnapshot)
- func (dh *DataHistory) Clear()
- func (dh *DataHistory) GetAll() HistoryData
- func (dh *DataHistory) GetHealth() []HealthSnapshot
- func (dh *DataHistory) GetMetrics() []MetricsSnapshot
- func (dh *DataHistory) GetOverview() []OverviewSnapshot
- type DataPoint
- type ExportFormat
- type Extension
- type HealthData
- type HealthSnapshot
- type HealthSummary
- type HistoryData
- type Hub
- type MetricActivity
- type MetricEntry
- type MetricsData
- type MetricsReport
- type MetricsReportStats
- type MetricsSnapshot
- type MetricsStats
- type OverviewData
- type OverviewSnapshot
- type ServiceDetail
- type ServiceHealth
- type ServiceInfo
- type TimeSeriesData
- type WSMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewExtension ¶
func NewExtension(opts ...ConfigOption) forge.Extension
NewExtension creates a new dashboard extension
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the hub
type CollectorInfo ¶
type CollectorInfo struct {
Name string `json:"name"`
Type string `json:"type"`
MetricsCount int `json:"metrics_count"`
LastCollection time.Time `json:"last_collection"`
Status string `json:"status"`
}
CollectorInfo contains information about a metrics collector
type Config ¶
type Config struct {
// Server settings
Port int `yaml:"port" json:"port"`
BasePath string `yaml:"base_path" json:"base_path"`
ReadTimeout time.Duration `yaml:"read_timeout" json:"read_timeout"`
WriteTimeout time.Duration `yaml:"write_timeout" json:"write_timeout"`
ShutdownTimeout time.Duration `yaml:"shutdown_timeout" json:"shutdown_timeout"`
// Features
EnableAuth bool `yaml:"enable_auth" json:"enable_auth"`
EnableRealtime bool `yaml:"enable_realtime" json:"enable_realtime"`
EnableExport bool `yaml:"enable_export" json:"enable_export"`
ExportFormats []string `yaml:"export_formats" json:"export_formats"`
// Data collection
RefreshInterval time.Duration `yaml:"refresh_interval" json:"refresh_interval"`
HistoryDuration time.Duration `yaml:"history_duration" json:"history_duration"`
MaxDataPoints int `yaml:"max_data_points" json:"max_data_points"`
// UI settings
Theme string `yaml:"theme" json:"theme"` // light, dark, auto
Title string `yaml:"title" json:"title"`
CustomCSS string `yaml:"custom_css" json:"custom_css"`
CustomJS string `yaml:"custom_js" json:"custom_js"`
MetaTags map[string]string `yaml:"meta_tags" json:"meta_tags"`
// Internal
RequireConfig bool `yaml:"-" json:"-"`
}
Config contains dashboard configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns default dashboard configuration
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption is a functional option for Config
func WithExport ¶
func WithExport(enabled bool) ConfigOption
WithExport enables/disables export functionality
func WithHistoryDuration ¶
func WithHistoryDuration(duration time.Duration) ConfigOption
WithHistoryDuration sets the data retention duration
func WithMaxDataPoints ¶
func WithMaxDataPoints(max int) ConfigOption
WithMaxDataPoints sets the maximum number of data points to retain
func WithRealtime ¶
func WithRealtime(enabled bool) ConfigOption
WithRealtime enables real-time updates
func WithRefreshInterval ¶
func WithRefreshInterval(interval time.Duration) ConfigOption
WithRefreshInterval sets the refresh interval
func WithRequireConfig ¶
func WithRequireConfig(required bool) ConfigOption
WithRequireConfig requires config from ConfigManager
type DashboardServer ¶
type DashboardServer struct {
// contains filtered or unexported fields
}
DashboardServer serves the dashboard HTTP interface
func NewDashboardServer ¶
func NewDashboardServer( config Config, healthManager forge.HealthManager, metrics forge.Metrics, logger forge.Logger, container shared.Container, ) *DashboardServer
NewDashboardServer creates a new dashboard server
func (*DashboardServer) GetCollector ¶
func (ds *DashboardServer) GetCollector() *DataCollector
GetCollector returns the data collector
func (*DashboardServer) GetHistory ¶
func (ds *DashboardServer) GetHistory() *DataHistory
GetHistory returns the data history
func (*DashboardServer) IsRunning ¶
func (ds *DashboardServer) IsRunning() bool
IsRunning returns true if the server is running
type DashboardSnapshot ¶
type DashboardSnapshot struct {
Timestamp time.Time `json:"timestamp"`
Overview OverviewData `json:"overview"`
Health HealthData `json:"health"`
Metrics MetricsData `json:"metrics"`
Services []ServiceInfo `json:"services"`
GeneratedBy string `json:"generated_by"`
}
DashboardSnapshot contains complete dashboard state for export
type DataCollector ¶
type DataCollector struct {
// contains filtered or unexported fields
}
DataCollector collects dashboard data periodically
func NewDataCollector ¶
func NewDataCollector( healthManager forge.HealthManager, metrics forge.Metrics, container shared.Container, logger forge.Logger, history *DataHistory, ) *DataCollector
NewDataCollector creates a new data collector
func (*DataCollector) CollectHealth ¶
func (dc *DataCollector) CollectHealth(ctx context.Context) *HealthData
CollectHealth collects health check data
func (*DataCollector) CollectMetrics ¶
func (dc *DataCollector) CollectMetrics(ctx context.Context) *MetricsData
CollectMetrics collects current metrics
func (*DataCollector) CollectMetricsReport ¶
func (dc *DataCollector) CollectMetricsReport(ctx context.Context) *MetricsReport
CollectMetricsReport collects comprehensive metrics report
func (*DataCollector) CollectOverview ¶
func (dc *DataCollector) CollectOverview(ctx context.Context) *OverviewData
CollectOverview collects overview data
func (*DataCollector) CollectServiceDetail ¶
func (dc *DataCollector) CollectServiceDetail(ctx context.Context, serviceName string) *ServiceDetail
CollectServiceDetail collects detailed information about a specific service
func (*DataCollector) CollectServices ¶
func (dc *DataCollector) CollectServices(ctx context.Context) []ServiceInfo
CollectServices collects service information with health status
type DataHistory ¶
type DataHistory struct {
// contains filtered or unexported fields
}
DataHistory manages historical time-series data with a ring buffer
func NewDataHistory ¶
func NewDataHistory(maxPoints int, retentionPeriod time.Duration) *DataHistory
NewDataHistory creates a new data history manager
func (*DataHistory) AddHealth ¶
func (dh *DataHistory) AddHealth(snapshot HealthSnapshot)
AddHealth adds a health snapshot
func (*DataHistory) AddMetrics ¶
func (dh *DataHistory) AddMetrics(snapshot MetricsSnapshot)
AddMetrics adds a metrics snapshot
func (*DataHistory) AddOverview ¶
func (dh *DataHistory) AddOverview(snapshot OverviewSnapshot)
AddOverview adds an overview snapshot
func (*DataHistory) GetAll ¶
func (dh *DataHistory) GetAll() HistoryData
GetAll returns all historical data
func (*DataHistory) GetHealth ¶
func (dh *DataHistory) GetHealth() []HealthSnapshot
GetHealth returns all health snapshots
func (*DataHistory) GetMetrics ¶
func (dh *DataHistory) GetMetrics() []MetricsSnapshot
GetMetrics returns all metrics snapshots
func (*DataHistory) GetOverview ¶
func (dh *DataHistory) GetOverview() []OverviewSnapshot
GetOverview returns all overview snapshots
type DataPoint ¶
type DataPoint struct {
Timestamp time.Time `json:"timestamp"`
Value float64 `json:"value"`
Labels map[string]string `json:"labels,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
DataPoint represents a time-series data point
type ExportFormat ¶
type ExportFormat string
ExportFormat represents data export format
const ( ExportFormatJSON ExportFormat = "json" ExportFormatCSV ExportFormat = "csv" ExportFormatPrometheus ExportFormat = "prometheus" )
type Extension ¶
type Extension struct {
*forge.BaseExtension
// contains filtered or unexported fields
}
Extension implements a simple health and metrics dashboard
func (*Extension) Dependencies ¶
Dependencies returns extension dependencies
func (*Extension) Server ¶
func (e *Extension) Server() *DashboardServer
Server returns the dashboard server instance (for advanced usage)
type HealthData ¶
type HealthData struct {
OverallStatus string `json:"overall_status"`
Services map[string]ServiceHealth `json:"services"`
CheckedAt time.Time `json:"checked_at"`
Duration time.Duration `json:"duration"`
Summary HealthSummary `json:"summary"`
}
HealthData contains health check results
type HealthSnapshot ¶
type HealthSnapshot struct {
Timestamp time.Time `json:"timestamp"`
OverallStatus string `json:"overall_status"`
HealthyCount int `json:"healthy_count"`
DegradedCount int `json:"degraded_count"`
UnhealthyCount int `json:"unhealthy_count"`
}
HealthSnapshot is a timestamped health snapshot
type HealthSummary ¶
type HealthSummary struct {
Healthy int `json:"healthy"`
Degraded int `json:"degraded"`
Unhealthy int `json:"unhealthy"`
Unknown int `json:"unknown"`
Total int `json:"total"`
}
HealthSummary provides count of services by status
type HistoryData ¶
type HistoryData struct {
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Series []TimeSeriesData `json:"series"`
}
HistoryData contains historical dashboard data
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub maintains the set of active clients and broadcasts messages to them
func (*Hub) ClientCount ¶
ClientCount returns the number of connected clients
type MetricActivity ¶
type MetricActivity struct {
Metric string `json:"metric"`
Action string `json:"action"`
Value float64 `json:"value"`
Timestamp time.Time `json:"timestamp"`
}
MetricActivity represents recent metric activity
type MetricEntry ¶
type MetricEntry struct {
Name string `json:"name"`
Type string `json:"type"`
Value interface{} `json:"value"`
Tags []string `json:"tags,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
MetricEntry represents a single metric entry
type MetricsData ¶
type MetricsData struct {
Timestamp time.Time `json:"timestamp"`
Metrics map[string]interface{} `json:"metrics"`
Stats MetricsStats `json:"stats"`
}
MetricsData contains current metrics information
type MetricsReport ¶
type MetricsReport struct {
Timestamp time.Time `json:"timestamp"`
TotalMetrics int `json:"total_metrics"`
MetricsByType map[string]int `json:"metrics_by_type"`
Collectors []CollectorInfo `json:"collectors"`
Stats MetricsReportStats `json:"stats"`
TopMetrics []MetricEntry `json:"top_metrics"`
RecentActivity []MetricActivity `json:"recent_activity"`
}
MetricsReport contains comprehensive metrics information
type MetricsReportStats ¶
type MetricsReportStats struct {
CollectionInterval time.Duration `json:"collection_interval"`
LastCollection time.Time `json:"last_collection"`
TotalCollections int64 `json:"total_collections"`
ErrorCount int `json:"error_count"`
Uptime time.Duration `json:"uptime"`
}
MetricsReportStats contains statistics about metrics
type MetricsSnapshot ¶
type MetricsSnapshot struct {
Timestamp time.Time `json:"timestamp"`
TotalMetrics int `json:"total_metrics"`
Values map[string]interface{} `json:"values"`
}
MetricsSnapshot is a timestamped metrics snapshot
type MetricsStats ¶
type MetricsStats struct {
TotalMetrics int `json:"total_metrics"`
Counters int `json:"counters"`
Gauges int `json:"gauges"`
Histograms int `json:"histograms"`
LastUpdate time.Time `json:"last_update"`
}
MetricsStats contains metrics statistics
type OverviewData ¶
type OverviewData struct {
Timestamp time.Time `json:"timestamp"`
OverallHealth string `json:"overall_health"`
TotalServices int `json:"total_services"`
HealthyServices int `json:"healthy_services"`
TotalMetrics int `json:"total_metrics"`
Uptime time.Duration `json:"uptime"`
Version string `json:"version"`
Environment string `json:"environment"`
Summary map[string]interface{} `json:"summary"`
}
OverviewData contains dashboard overview information
type OverviewSnapshot ¶
type OverviewSnapshot struct {
Timestamp time.Time `json:"timestamp"`
HealthStatus string `json:"health_status"`
ServiceCount int `json:"service_count"`
HealthyCount int `json:"healthy_count"`
MetricsCount int `json:"metrics_count"`
}
OverviewSnapshot is a timestamped overview snapshot
type ServiceDetail ¶
type ServiceDetail struct {
Name string `json:"name"`
Type string `json:"type"`
Status string `json:"status"`
Health *ServiceHealth `json:"health,omitempty"`
Metrics map[string]interface{} `json:"metrics"`
Dependencies []string `json:"dependencies"`
Configuration map[string]interface{} `json:"configuration,omitempty"`
LastHealthCheck time.Time `json:"last_health_check"`
Uptime time.Duration `json:"uptime,omitempty"`
}
ServiceDetail contains detailed information about a specific service
type ServiceHealth ¶
type ServiceHealth struct {
Name string `json:"name"`
Status string `json:"status"`
Message string `json:"message"`
Duration time.Duration `json:"duration"`
Critical bool `json:"critical"`
Timestamp time.Time `json:"timestamp"`
Details map[string]interface{} `json:"details,omitempty"`
}
ServiceHealth contains individual service health information
type ServiceInfo ¶
type ServiceInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Status string `json:"status"`
RegisteredAt time.Time `json:"registered_at,omitempty"`
}
ServiceInfo contains information about a registered service
type TimeSeriesData ¶
type TimeSeriesData struct {
Name string `json:"name"`
Points []DataPoint `json:"points"`
Unit string `json:"unit,omitempty"`
Aggregation string `json:"aggregation,omitempty"`
}
TimeSeriesData contains time-series data