Documentation
¶
Overview ¶
Package detector provides thread-safe statistics tracking for the Problem Detector.
Index ¶
- type MonitorFactory
- type MonitorHandle
- type ProblemDetector
- type Statistics
- func (s *Statistics) AddProblemsDeduplicated(count int)
- func (s *Statistics) AddProblemsDetected(count int)
- func (s *Statistics) Copy() Statistics
- func (s *Statistics) GetDeduplicationRate() float64
- func (s *Statistics) GetExportSuccessRate() float64
- func (s *Statistics) GetExportsFailed() int64
- func (s *Statistics) GetExportsSucceeded() int64
- func (s *Statistics) GetMonitorsFailed() int64
- func (s *Statistics) GetMonitorsStarted() int64
- func (s *Statistics) GetProblemsDeduplicated() int64
- func (s *Statistics) GetProblemsDetected() int64
- func (s *Statistics) GetStartTime() time.Time
- func (s *Statistics) GetStatusesReceived() int64
- func (s *Statistics) GetTotalExports() int64
- func (s *Statistics) GetUptime() time.Duration
- func (s *Statistics) IncrementExportsFailed()
- func (s *Statistics) IncrementExportsSucceeded()
- func (s *Statistics) IncrementMonitorsFailed()
- func (s *Statistics) IncrementMonitorsStarted()
- func (s *Statistics) IncrementStatusesReceived()
- func (s *Statistics) Reset()
- func (s *Statistics) Summary() map[string]interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MonitorFactory ¶
type MonitorFactory interface {
CreateMonitor(config types.MonitorConfig) (types.Monitor, error)
}
MonitorFactory interface for creating monitor instances during hot reload
type MonitorHandle ¶
type MonitorHandle struct {
// contains filtered or unexported fields
}
MonitorHandle represents a running monitor with its context and controls
func (*MonitorHandle) GetConfig ¶
func (mh *MonitorHandle) GetConfig() types.MonitorConfig
GetConfig returns the configuration of the monitor
func (*MonitorHandle) GetName ¶
func (mh *MonitorHandle) GetName() string
GetName returns the name of the monitor
func (*MonitorHandle) IsRunning ¶
func (mh *MonitorHandle) IsRunning() bool
IsRunning returns true if the monitor is currently running
func (*MonitorHandle) Stop ¶
func (mh *MonitorHandle) Stop() error
Stop stops the monitor gracefully with a timeout
type ProblemDetector ¶
type ProblemDetector struct {
// contains filtered or unexported fields
}
ProblemDetector manages monitors and exports their output
func NewProblemDetector ¶
func NewProblemDetector(config *types.NodeDoctorConfig, monitors []types.Monitor, exporters []types.Exporter, configFilePath string, monitorFactory MonitorFactory) (*ProblemDetector, error)
NewProblemDetector creates a new problem detector with the given configuration
func (*ProblemDetector) AddExporter ¶
func (pd *ProblemDetector) AddExporter(exporter types.Exporter)
AddExporter adds an exporter to the detector
func (*ProblemDetector) GetStatistics ¶
func (pd *ProblemDetector) GetStatistics() Statistics
GetStatistics returns the current statistics (copy to avoid lock sharing)
func (*ProblemDetector) IsRunning ¶
func (pd *ProblemDetector) IsRunning() bool
IsRunning returns true if the detector is currently running
func (*ProblemDetector) Run ¶
func (pd *ProblemDetector) Run() error
Run starts the problem detector (alias for Start for backward compatibility)
func (*ProblemDetector) Start ¶
func (pd *ProblemDetector) Start() error
Start starts the problem detector
func (*ProblemDetector) Stop ¶
func (pd *ProblemDetector) Stop() error
Stop stops the problem detector gracefully
type Statistics ¶
type Statistics struct {
// contains filtered or unexported fields
}
Statistics tracks operational metrics for the Problem Detector. All methods are thread-safe and can be called concurrently.
func NewStatistics ¶
func NewStatistics() *Statistics
NewStatistics creates a new Statistics instance with current timestamp.
func (*Statistics) AddProblemsDeduplicated ¶
func (s *Statistics) AddProblemsDeduplicated(count int)
AddProblemsDeduplicated atomically adds to the problems deduplicated counter.
func (*Statistics) AddProblemsDetected ¶
func (s *Statistics) AddProblemsDetected(count int)
AddProblemsDetected atomically adds to the problems detected counter.
func (*Statistics) Copy ¶
func (s *Statistics) Copy() Statistics
Copy returns a complete copy of the current statistics. This is useful for taking a snapshot without holding the lock.
func (*Statistics) GetDeduplicationRate ¶
func (s *Statistics) GetDeduplicationRate() float64
GetDeduplicationRate returns the deduplication rate as a percentage (0-100). This shows what percentage of detected problems were new after deduplication. Returns 0 if no problems have been detected.
func (*Statistics) GetExportSuccessRate ¶
func (s *Statistics) GetExportSuccessRate() float64
GetExportSuccessRate returns the export success rate as a percentage (0-100). Returns 0 if no exports have been attempted.
func (*Statistics) GetExportsFailed ¶
func (s *Statistics) GetExportsFailed() int64
GetExportsFailed returns the number of failed export operations.
func (*Statistics) GetExportsSucceeded ¶
func (s *Statistics) GetExportsSucceeded() int64
GetExportsSucceeded returns the number of successful export operations.
func (*Statistics) GetMonitorsFailed ¶
func (s *Statistics) GetMonitorsFailed() int64
GetMonitorsFailed returns the number of monitors that failed to start.
func (*Statistics) GetMonitorsStarted ¶
func (s *Statistics) GetMonitorsStarted() int64
GetMonitorsStarted returns the number of monitors successfully started.
func (*Statistics) GetProblemsDeduplicated ¶
func (s *Statistics) GetProblemsDeduplicated() int64
GetProblemsDeduplicated returns the total number of problems after deduplication.
func (*Statistics) GetProblemsDetected ¶
func (s *Statistics) GetProblemsDetected() int64
GetProblemsDetected returns the total number of problems detected.
func (*Statistics) GetStartTime ¶
func (s *Statistics) GetStartTime() time.Time
GetStartTime returns when statistics tracking started.
func (*Statistics) GetStatusesReceived ¶
func (s *Statistics) GetStatusesReceived() int64
GetStatusesReceived returns the total number of status updates received.
func (*Statistics) GetTotalExports ¶
func (s *Statistics) GetTotalExports() int64
GetTotalExports returns the total number of export operations (successful + failed).
func (*Statistics) GetUptime ¶
func (s *Statistics) GetUptime() time.Duration
GetUptime returns how long statistics have been tracked.
func (*Statistics) IncrementExportsFailed ¶
func (s *Statistics) IncrementExportsFailed()
IncrementExportsFailed atomically increments the failed exports counter.
func (*Statistics) IncrementExportsSucceeded ¶
func (s *Statistics) IncrementExportsSucceeded()
IncrementExportsSucceeded atomically increments the successful exports counter.
func (*Statistics) IncrementMonitorsFailed ¶
func (s *Statistics) IncrementMonitorsFailed()
IncrementMonitorsFailed atomically increments the monitors failed counter.
func (*Statistics) IncrementMonitorsStarted ¶
func (s *Statistics) IncrementMonitorsStarted()
IncrementMonitorsStarted atomically increments the monitors started counter.
func (*Statistics) IncrementStatusesReceived ¶
func (s *Statistics) IncrementStatusesReceived()
IncrementStatusesReceived atomically increments the statuses received counter.
func (*Statistics) Reset ¶
func (s *Statistics) Reset()
Reset resets all counters to zero and updates the start time. This is primarily useful for testing scenarios.
func (*Statistics) Summary ¶
func (s *Statistics) Summary() map[string]interface{}
Summary returns a human-readable summary of all statistics.