Documentation
¶
Index ¶
- func GenerateDashboardHTML(config Config) string
- 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 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 DashboardServerdeprecated
- 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
- func (e *Extension) Collector() *DataCollector
- func (e *Extension) Dependencies() []string
- func (e *Extension) Health(ctx context.Context) error
- func (e *Extension) History() *DataHistory
- func (e *Extension) Register(app forge.App) error
- func (e *Extension) Start(ctx context.Context) error
- func (e *Extension) Stop(ctx context.Context) error
- type ForgeUIIntegration
- 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 GenerateDashboardHTML ¶ added in v0.8.0
GenerateDashboardHTML returns the complete dashboard HTML based on config.
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
BasePath string `json:"base_path" yaml:"base_path"`
// Features
EnableAuth bool `json:"enable_auth" yaml:"enable_auth"`
EnableRealtime bool `json:"enable_realtime" yaml:"enable_realtime"`
EnableExport bool `json:"enable_export" yaml:"enable_export"`
ExportFormats []string `json:"export_formats" yaml:"export_formats"`
// Data collection
RefreshInterval time.Duration `json:"refresh_interval" yaml:"refresh_interval"`
HistoryDuration time.Duration `json:"history_duration" yaml:"history_duration"`
MaxDataPoints int `json:"max_data_points" yaml:"max_data_points"`
// UI settings
Theme string `json:"theme" yaml:"theme"` // light, dark, auto
Title string `json:"title" yaml:"title"`
CustomCSS string `json:"custom_css" yaml:"custom_css"`
CustomJS string `json:"custom_js" yaml:"custom_js"`
MetaTags map[string]string `json:"meta_tags" yaml:"meta_tags"`
// Internal
RequireConfig bool `json:"-" yaml:"-"`
}
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 WithBasePath ¶
func WithBasePath(path string) ConfigOption
WithBasePath sets the base URL path.
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
deprecated
type DashboardServer struct {
// contains filtered or unexported fields
}
DashboardServer serves the dashboard HTTP interface.
Deprecated: DashboardServer is deprecated. Use the dashboard Extension instead, which integrates directly with the app's router. For custom integrations, see ForgeUIIntegration for ForgeUI router support.
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) Collector ¶ added in v0.8.0
func (e *Extension) Collector() *DataCollector
Collector returns the data collector instance (for advanced usage).
func (*Extension) Dependencies ¶
Dependencies returns extension dependencies.
func (*Extension) History ¶ added in v0.8.0
func (e *Extension) History() *DataHistory
History returns the data history instance (for advanced usage).
type ForgeUIIntegration ¶ added in v0.8.0
type ForgeUIIntegration struct {
// contains filtered or unexported fields
}
ForgeUIIntegration provides ForgeUI-specific functionality for the dashboard
func NewForgeUIIntegration ¶ added in v0.8.0
func NewForgeUIIntegration( config Config, healthManager forge.HealthManager, metrics forge.Metrics, logger forge.Logger, container forge.Container, ) *ForgeUIIntegration
NewForgeUIIntegration creates a new ForgeUI integration for the dashboard
func (*ForgeUIIntegration) RegisterRoutes ¶ added in v0.8.0
func (fi *ForgeUIIntegration) RegisterRoutes(r *router.Router)
RegisterRoutes registers dashboard routes with a ForgeUI router
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]any `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.