Documentation
¶
Index ¶
- func GetSpanContext(ctx context.Context) (string, bool)
- func GetTraceContext(ctx context.Context) (string, bool)
- type Alert
- type AlertCondition
- type AlertConfig
- type AlertEvent
- type AlertEventType
- type AlertHandler
- type AlertManager
- func (am *AlertManager) AcknowledgeAlert(alertID string) error
- func (am *AlertManager) ClearResolvedAlerts() int
- func (am *AlertManager) DisableRule(ruleName string) error
- func (am *AlertManager) EnableRule(ruleName string) error
- func (am *AlertManager) EvaluateRule(ctx context.Context, ruleName string, data map[string]interface{})
- func (am *AlertManager) GetActiveAlerts() []*Alert
- func (am *AlertManager) GetAlertsBySeverity(severity AlertSeverity) []*Alert
- func (am *AlertManager) GetCriticalAlerts() []*Alert
- func (am *AlertManager) GetHistory(limit int) []AlertEvent
- func (am *AlertManager) GetStatistics() AlertStatistics
- func (am *AlertManager) MonitorAlerts(ctx context.Context, interval time.Duration, ...)
- func (am *AlertManager) RegisterHandler(handler AlertHandler)
- func (am *AlertManager) RegisterRule(rule *AlertRule)
- func (am *AlertManager) ResolveAlert(alertID string) error
- type AlertRule
- type AlertSeverity
- type AlertStatistics
- type HealthCheckFunc
- type HealthChecker
- func (hc *HealthChecker) Check(ctx context.Context) internal.HealthStatus
- func (hc *HealthChecker) GetHealthStatus(ctx context.Context) internal.HealthStatus
- func (hc *HealthChecker) IsHealthy(ctx context.Context) bool
- func (hc *HealthChecker) RegisterCheck(name string, fn HealthCheckFunc)
- func (hc *HealthChecker) UnregisterCheck(name string)
- type HealthCheckerConfig
- type LogConfig
- type LogEntry
- type LogFilter
- type LogLevel
- type LogManager
- func (lm *LogManager) ClearBuffer()
- func (lm *LogManager) Debug(ctx context.Context, operation, message string, fields ...interface{})
- func (lm *LogManager) Error(ctx context.Context, operation, message string, fields ...interface{})
- func (lm *LogManager) ExportLogs(filter LogFilter) []map[string]interface{}
- func (lm *LogManager) GetBuffer(limit int) []LogEntry
- func (lm *LogManager) GetErrorLogs(limit int) []LogEntry
- func (lm *LogManager) GetLogsByLevel(level LogLevel, limit int) []LogEntry
- func (lm *LogManager) GetLogsByOperation(operation string, limit int) []LogEntry
- func (lm *LogManager) GetLogsByTrace(traceID string) []LogEntry
- func (lm *LogManager) GetRecentLogs(duration time.Duration, limit int) []LogEntry
- func (lm *LogManager) GetStatistics() LogStatistics
- func (lm *LogManager) GetWarningLogs(limit int) []LogEntry
- func (lm *LogManager) Info(ctx context.Context, operation, message string, fields ...interface{})
- func (lm *LogManager) LogClusterChange(ctx context.Context, event string, nodeID string, memberCount int)
- func (lm *LogManager) LogElection(ctx context.Context, event string, term uint64, candidateID string)
- func (lm *LogManager) LogPerformance(ctx context.Context, operation string, duration time.Duration, success bool)
- func (lm *LogManager) LogReplication(ctx context.Context, event string, followerID string, index uint64)
- func (lm *LogManager) LogSnapshot(ctx context.Context, event string, index uint64, size int64)
- func (lm *LogManager) LogStateChange(ctx context.Context, event string, index uint64)
- func (lm *LogManager) SearchLogs(filter LogFilter) []LogEntry
- func (lm *LogManager) Warn(ctx context.Context, operation, message string, fields ...interface{})
- type LogStatistics
- type MetricsCollector
- func (mc *MetricsCollector) GetMetrics() map[string]interface{}
- func (mc *MetricsCollector) RecordApplyLatency(latencyMs float64)
- func (mc *MetricsCollector) RecordConfigChange()
- func (mc *MetricsCollector) RecordElection(success bool)
- func (mc *MetricsCollector) RecordLeadershipTransfer()
- func (mc *MetricsCollector) RecordLogAppend(success bool)
- func (mc *MetricsCollector) RecordReplicationLatency(latencyMs float64)
- func (mc *MetricsCollector) RecordSnapshot(success bool)
- func (mc *MetricsCollector) Start(ctx context.Context) error
- func (mc *MetricsCollector) Stop(ctx context.Context) error
- func (mc *MetricsCollector) UpdateGauges(stats internal.ConsensusStats)
- type MetricsConfig
- type Span
- type SpanLog
- type SpanStatus
- type Trace
- type TraceStatus
- type TracingConfig
- type TracingManager
- func (tm *TracingManager) AddSpanLog(span *Span, message string, fields map[string]interface{})
- func (tm *TracingManager) ClearOldTraces(olderThan time.Duration) int
- func (tm *TracingManager) EndSpan(span *Span, err error)
- func (tm *TracingManager) EndTrace(trace *Trace, err error)
- func (tm *TracingManager) ExportTrace(traceID string) (map[string]interface{}, error)
- func (tm *TracingManager) GetActiveTraces() []*Trace
- func (tm *TracingManager) GetStatistics() TracingStatistics
- func (tm *TracingManager) GetTrace(traceID string) (*Trace, error)
- func (tm *TracingManager) SetSpanTag(span *Span, key string, value interface{})
- func (tm *TracingManager) SetTraceTag(trace *Trace, key string, value interface{})
- func (tm *TracingManager) StartSpan(ctx context.Context, operation string) (*Span, context.Context)
- func (tm *TracingManager) StartTrace(ctx context.Context, operation string) (*Trace, context.Context)
- type TracingStatistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSpanContext ¶
GetSpanContext retrieves span context from context.Context
Types ¶
type Alert ¶
type Alert struct {
ID string
Rule string
Severity AlertSeverity
Message string
Details map[string]interface{}
StartTime time.Time
LastUpdate time.Time
FireCount int
Acknowledged bool
Resolved bool
ResolvedAt time.Time
}
Alert represents an active alert
type AlertCondition ¶
AlertCondition is a function that evaluates alert conditions
type AlertConfig ¶
AlertConfig contains alert configuration
type AlertEvent ¶
type AlertEvent struct {
Timestamp time.Time
Type AlertEventType
AlertID string
Rule string
Severity AlertSeverity
Message string
}
AlertEvent represents an alert event in history
type AlertEventType ¶
type AlertEventType string
AlertEventType represents alert event type
const ( // AlertEventTypeFired alert fired AlertEventTypeFired AlertEventType = "fired" // AlertEventTypeAcknowledged alert acknowledged AlertEventTypeAcknowledged AlertEventType = "acknowledged" // AlertEventTypeResolved alert resolved AlertEventTypeResolved AlertEventType = "resolved" )
type AlertManager ¶
type AlertManager struct {
// contains filtered or unexported fields
}
AlertManager manages alerts and notifications for consensus issues
func NewAlertManager ¶
func NewAlertManager(nodeID string, config AlertConfig, logger forge.Logger) *AlertManager
NewAlertManager creates a new alert manager
func (*AlertManager) AcknowledgeAlert ¶
func (am *AlertManager) AcknowledgeAlert(alertID string) error
AcknowledgeAlert acknowledges an alert
func (*AlertManager) ClearResolvedAlerts ¶
func (am *AlertManager) ClearResolvedAlerts() int
ClearResolvedAlerts clears resolved alerts from memory
func (*AlertManager) DisableRule ¶
func (am *AlertManager) DisableRule(ruleName string) error
DisableRule disables an alert rule
func (*AlertManager) EnableRule ¶
func (am *AlertManager) EnableRule(ruleName string) error
EnableRule enables an alert rule
func (*AlertManager) EvaluateRule ¶
func (am *AlertManager) EvaluateRule(ctx context.Context, ruleName string, data map[string]interface{})
EvaluateRule evaluates an alert rule
func (*AlertManager) GetActiveAlerts ¶
func (am *AlertManager) GetActiveAlerts() []*Alert
GetActiveAlerts returns all active alerts
func (*AlertManager) GetAlertsBySeverity ¶
func (am *AlertManager) GetAlertsBySeverity(severity AlertSeverity) []*Alert
GetAlertsBySeverity returns alerts by severity
func (*AlertManager) GetCriticalAlerts ¶
func (am *AlertManager) GetCriticalAlerts() []*Alert
GetCriticalAlerts returns critical alerts
func (*AlertManager) GetHistory ¶
func (am *AlertManager) GetHistory(limit int) []AlertEvent
GetHistory returns alert history
func (*AlertManager) GetStatistics ¶
func (am *AlertManager) GetStatistics() AlertStatistics
GetStatistics returns alert statistics
func (*AlertManager) MonitorAlerts ¶
func (am *AlertManager) MonitorAlerts(ctx context.Context, interval time.Duration, dataProvider func() map[string]interface{})
MonitorAlerts monitors and evaluates alert rules
func (*AlertManager) RegisterHandler ¶
func (am *AlertManager) RegisterHandler(handler AlertHandler)
RegisterHandler registers an alert handler
func (*AlertManager) RegisterRule ¶
func (am *AlertManager) RegisterRule(rule *AlertRule)
RegisterRule registers a new alert rule
func (*AlertManager) ResolveAlert ¶
func (am *AlertManager) ResolveAlert(alertID string) error
ResolveAlert resolves an alert
type AlertRule ¶
type AlertRule struct {
Name string
Condition AlertCondition
Severity AlertSeverity
Description string
Enabled bool
Cooldown time.Duration
// contains filtered or unexported fields
}
AlertRule defines conditions for triggering alerts
type AlertSeverity ¶
type AlertSeverity string
AlertSeverity represents alert severity
const ( // AlertSeverityCritical critical severity AlertSeverityCritical AlertSeverity = "critical" // AlertSeverityHigh high severity AlertSeverityHigh AlertSeverity = "high" // AlertSeverityMedium medium severity AlertSeverityMedium AlertSeverity = "medium" // AlertSeverityLow low severity AlertSeverityLow AlertSeverity = "low" )
type AlertStatistics ¶
type AlertStatistics struct {
TotalAlerts int64
ActiveAlerts int64
CriticalAlerts int64
HighAlerts int64
MediumAlerts int64
LowAlerts int64
AcknowledgedAlerts int64
ResolvedAlerts int64
}
AlertStatistics contains alert statistics
type HealthCheckFunc ¶
type HealthCheckFunc func(ctx context.Context) internal.HealthCheck
HealthCheckFunc is a function that performs a health check
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker performs comprehensive health checks
func NewHealthChecker ¶
func NewHealthChecker( config HealthCheckerConfig, logger forge.Logger, raftNode internal.RaftNode, clusterManager internal.ClusterManager, storage internal.Storage, transport internal.Transport, ) *HealthChecker
NewHealthChecker creates a new health checker
func (*HealthChecker) Check ¶
func (hc *HealthChecker) Check(ctx context.Context) internal.HealthStatus
Check performs all health checks
func (*HealthChecker) GetHealthStatus ¶
func (hc *HealthChecker) GetHealthStatus(ctx context.Context) internal.HealthStatus
GetHealthStatus returns the current health status
func (*HealthChecker) IsHealthy ¶
func (hc *HealthChecker) IsHealthy(ctx context.Context) bool
IsHealthy returns true if the system is healthy
func (*HealthChecker) RegisterCheck ¶
func (hc *HealthChecker) RegisterCheck(name string, fn HealthCheckFunc)
RegisterCheck registers a custom health check
func (*HealthChecker) UnregisterCheck ¶
func (hc *HealthChecker) UnregisterCheck(name string)
UnregisterCheck unregisters a health check
type HealthCheckerConfig ¶
HealthCheckerConfig contains health checker configuration
type LogConfig ¶
type LogConfig struct {
EnableBuffer bool
BufferSize int
EnableTracing bool
EnableStructured bool
SampleRate float64
}
LogConfig contains logging configuration
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time
Level LogLevel
Operation string
Message string
Fields map[string]interface{}
TraceID string
SpanID string
NodeID string
}
LogEntry represents a structured log entry
type LogFilter ¶
type LogFilter struct {
Level LogLevel
Operation string
TraceID string
StartTime time.Time
EndTime time.Time
}
LogFilter filters log entries
type LogManager ¶
type LogManager struct {
// contains filtered or unexported fields
}
LogManager manages structured logging for consensus operations
func NewLogManager ¶
func NewLogManager(nodeID string, config LogConfig, logger forge.Logger) *LogManager
NewLogManager creates a new log manager
func (*LogManager) ClearBuffer ¶
func (lm *LogManager) ClearBuffer()
ClearBuffer clears the log buffer
func (*LogManager) Debug ¶
func (lm *LogManager) Debug(ctx context.Context, operation, message string, fields ...interface{})
Debug logs a debug message
func (*LogManager) Error ¶
func (lm *LogManager) Error(ctx context.Context, operation, message string, fields ...interface{})
Error logs an error message
func (*LogManager) ExportLogs ¶
func (lm *LogManager) ExportLogs(filter LogFilter) []map[string]interface{}
ExportLogs exports logs in structured format
func (*LogManager) GetBuffer ¶
func (lm *LogManager) GetBuffer(limit int) []LogEntry
GetBuffer returns buffered log entries
func (*LogManager) GetErrorLogs ¶
func (lm *LogManager) GetErrorLogs(limit int) []LogEntry
GetErrorLogs returns error logs
func (*LogManager) GetLogsByLevel ¶
func (lm *LogManager) GetLogsByLevel(level LogLevel, limit int) []LogEntry
GetLogsByLevel returns logs filtered by level
func (*LogManager) GetLogsByOperation ¶
func (lm *LogManager) GetLogsByOperation(operation string, limit int) []LogEntry
GetLogsByOperation returns logs for a specific operation
func (*LogManager) GetLogsByTrace ¶
func (lm *LogManager) GetLogsByTrace(traceID string) []LogEntry
GetLogsByTrace returns logs for a specific trace
func (*LogManager) GetRecentLogs ¶
func (lm *LogManager) GetRecentLogs(duration time.Duration, limit int) []LogEntry
GetRecentLogs returns most recent logs
func (*LogManager) GetStatistics ¶
func (lm *LogManager) GetStatistics() LogStatistics
GetStatistics returns logging statistics
func (*LogManager) GetWarningLogs ¶
func (lm *LogManager) GetWarningLogs(limit int) []LogEntry
GetWarningLogs returns warning logs
func (*LogManager) Info ¶
func (lm *LogManager) Info(ctx context.Context, operation, message string, fields ...interface{})
Info logs an info message
func (*LogManager) LogClusterChange ¶
func (lm *LogManager) LogClusterChange(ctx context.Context, event string, nodeID string, memberCount int)
LogClusterChange logs cluster membership changes
func (*LogManager) LogElection ¶
func (lm *LogManager) LogElection(ctx context.Context, event string, term uint64, candidateID string)
LogElection logs election-related events
func (*LogManager) LogPerformance ¶
func (lm *LogManager) LogPerformance(ctx context.Context, operation string, duration time.Duration, success bool)
LogPerformance logs performance metrics
func (*LogManager) LogReplication ¶
func (lm *LogManager) LogReplication(ctx context.Context, event string, followerID string, index uint64)
LogReplication logs replication events
func (*LogManager) LogSnapshot ¶
LogSnapshot logs snapshot events
func (*LogManager) LogStateChange ¶
func (lm *LogManager) LogStateChange(ctx context.Context, event string, index uint64)
LogStateChange logs state machine changes
func (*LogManager) SearchLogs ¶
func (lm *LogManager) SearchLogs(filter LogFilter) []LogEntry
SearchLogs searches buffered logs
type LogStatistics ¶
type LogStatistics struct {
TotalLogs int64
DebugLogs int64
InfoLogs int64
WarnLogs int64
ErrorLogs int64
BufferedLogs int
}
LogStatistics contains logging statistics
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector collects and exports consensus metrics
func NewMetricsCollector ¶
func NewMetricsCollector(config MetricsConfig, metrics forge.Metrics, logger forge.Logger) *MetricsCollector
NewMetricsCollector creates a new metrics collector
func (*MetricsCollector) GetMetrics ¶
func (mc *MetricsCollector) GetMetrics() map[string]interface{}
GetMetrics returns current metrics as a map
func (*MetricsCollector) RecordApplyLatency ¶
func (mc *MetricsCollector) RecordApplyLatency(latencyMs float64)
RecordApplyLatency records a state machine apply latency
func (*MetricsCollector) RecordConfigChange ¶
func (mc *MetricsCollector) RecordConfigChange()
RecordConfigChange records a configuration change
func (*MetricsCollector) RecordElection ¶
func (mc *MetricsCollector) RecordElection(success bool)
RecordElection records an election event
func (*MetricsCollector) RecordLeadershipTransfer ¶
func (mc *MetricsCollector) RecordLeadershipTransfer()
RecordLeadershipTransfer records a leadership transfer
func (*MetricsCollector) RecordLogAppend ¶
func (mc *MetricsCollector) RecordLogAppend(success bool)
RecordLogAppend records a log append event
func (*MetricsCollector) RecordReplicationLatency ¶
func (mc *MetricsCollector) RecordReplicationLatency(latencyMs float64)
RecordReplicationLatency records a replication latency
func (*MetricsCollector) RecordSnapshot ¶
func (mc *MetricsCollector) RecordSnapshot(success bool)
RecordSnapshot records a snapshot event
func (*MetricsCollector) Start ¶
func (mc *MetricsCollector) Start(ctx context.Context) error
Start starts the metrics collector
func (*MetricsCollector) Stop ¶
func (mc *MetricsCollector) Stop(ctx context.Context) error
Stop stops the metrics collector
func (*MetricsCollector) UpdateGauges ¶
func (mc *MetricsCollector) UpdateGauges(stats internal.ConsensusStats)
UpdateGauges updates gauge metrics
type MetricsConfig ¶
type MetricsConfig struct {
NodeID string
CollectionInterval time.Duration
EnableHistograms bool
HistogramSize int
}
MetricsConfig contains metrics collector configuration
type Span ¶
type Span struct {
SpanID string
ParentID string
TraceID string
Operation string
StartTime time.Time
EndTime time.Time
Duration time.Duration
Tags map[string]interface{}
Logs []SpanLog
Status SpanStatus
}
Span represents a span within a trace
type SpanStatus ¶
type SpanStatus string
SpanStatus represents span status
const ( // SpanStatusActive span is active SpanStatusActive SpanStatus = "active" // SpanStatusComplete span completed successfully SpanStatusComplete SpanStatus = "complete" // SpanStatusError span completed with error SpanStatusError SpanStatus = "error" )
type Trace ¶
type Trace struct {
TraceID string
OperationID string
Operation string
StartTime time.Time
EndTime time.Time
Duration time.Duration
Spans []*Span
Tags map[string]interface{}
Status TraceStatus
// contains filtered or unexported fields
}
Trace represents a distributed trace
type TraceStatus ¶
type TraceStatus string
TraceStatus represents trace status
const ( // TraceStatusActive trace is active TraceStatusActive TraceStatus = "active" // TraceStatusComplete trace completed successfully TraceStatusComplete TraceStatus = "complete" // TraceStatusError trace completed with error TraceStatusError TraceStatus = "error" )
type TracingConfig ¶
type TracingConfig struct {
Enabled bool
SampleRate float64 // 0.0 to 1.0
MaxTraces int
MaxSpansPerTrace int
}
TracingConfig contains tracing configuration
type TracingManager ¶
type TracingManager struct {
// contains filtered or unexported fields
}
TracingManager manages distributed tracing for consensus operations
func NewTracingManager ¶
func NewTracingManager(config TracingConfig, logger forge.Logger) *TracingManager
NewTracingManager creates a new tracing manager
func (*TracingManager) AddSpanLog ¶
func (tm *TracingManager) AddSpanLog(span *Span, message string, fields map[string]interface{})
AddSpanLog adds a log to a span
func (*TracingManager) ClearOldTraces ¶
func (tm *TracingManager) ClearOldTraces(olderThan time.Duration) int
ClearOldTraces clears traces older than duration
func (*TracingManager) EndSpan ¶
func (tm *TracingManager) EndSpan(span *Span, err error)
EndSpan ends a span
func (*TracingManager) EndTrace ¶
func (tm *TracingManager) EndTrace(trace *Trace, err error)
EndTrace ends a trace
func (*TracingManager) ExportTrace ¶
func (tm *TracingManager) ExportTrace(traceID string) (map[string]interface{}, error)
ExportTrace exports a trace in a structured format
func (*TracingManager) GetActiveTraces ¶
func (tm *TracingManager) GetActiveTraces() []*Trace
GetActiveTraces returns all active traces
func (*TracingManager) GetStatistics ¶
func (tm *TracingManager) GetStatistics() TracingStatistics
GetStatistics returns tracing statistics
func (*TracingManager) GetTrace ¶
func (tm *TracingManager) GetTrace(traceID string) (*Trace, error)
GetTrace retrieves a trace by ID
func (*TracingManager) SetSpanTag ¶
func (tm *TracingManager) SetSpanTag(span *Span, key string, value interface{})
SetSpanTag sets a tag on a span
func (*TracingManager) SetTraceTag ¶
func (tm *TracingManager) SetTraceTag(trace *Trace, key string, value interface{})
SetTraceTag sets a tag on a trace
func (*TracingManager) StartTrace ¶
func (tm *TracingManager) StartTrace(ctx context.Context, operation string) (*Trace, context.Context)
StartTrace starts a new trace