refactor CHORUS
This commit is contained in:
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
// BZZZMetrics provides comprehensive Prometheus metrics for the CHORUS system
|
||||
type BZZZMetrics struct {
|
||||
// CHORUSMetrics provides comprehensive Prometheus metrics for the CHORUS system
|
||||
type CHORUSMetrics struct {
|
||||
registry *prometheus.Registry
|
||||
httpServer *http.Server
|
||||
|
||||
@@ -138,15 +138,15 @@ func DefaultMetricsConfig() *MetricsConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// NewBZZZMetrics creates a new metrics collector
|
||||
func NewBZZZMetrics(config *MetricsConfig) *BZZZMetrics {
|
||||
// NewCHORUSMetrics creates a new metrics collector
|
||||
func NewCHORUSMetrics(config *MetricsConfig) *CHORUSMetrics {
|
||||
if config == nil {
|
||||
config = DefaultMetricsConfig()
|
||||
}
|
||||
|
||||
registry := prometheus.NewRegistry()
|
||||
|
||||
metrics := &BZZZMetrics{
|
||||
metrics := &CHORUSMetrics{
|
||||
registry: registry,
|
||||
startTime: time.Now(),
|
||||
}
|
||||
@@ -161,11 +161,11 @@ func NewBZZZMetrics(config *MetricsConfig) *BZZZMetrics {
|
||||
}
|
||||
|
||||
// initializeMetrics initializes all Prometheus metrics
|
||||
func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
func (m *CHORUSMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// System metrics
|
||||
m.systemInfo = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_system_info",
|
||||
Name: "chorus_system_info",
|
||||
Help: "System information",
|
||||
},
|
||||
[]string{"node_id", "version", "go_version", "cluster", "environment"},
|
||||
@@ -173,7 +173,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.uptime = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_uptime_seconds",
|
||||
Name: "chorus_uptime_seconds",
|
||||
Help: "System uptime in seconds",
|
||||
},
|
||||
)
|
||||
@@ -181,14 +181,14 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// P2P metrics
|
||||
m.p2pConnectedPeers = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_p2p_connected_peers",
|
||||
Name: "chorus_p2p_connected_peers",
|
||||
Help: "Number of connected P2P peers",
|
||||
},
|
||||
)
|
||||
|
||||
m.p2pMessagesSent = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_p2p_messages_sent_total",
|
||||
Name: "chorus_p2p_messages_sent_total",
|
||||
Help: "Total number of P2P messages sent",
|
||||
},
|
||||
[]string{"message_type", "peer_id"},
|
||||
@@ -196,7 +196,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.p2pMessagesReceived = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_p2p_messages_received_total",
|
||||
Name: "chorus_p2p_messages_received_total",
|
||||
Help: "Total number of P2P messages received",
|
||||
},
|
||||
[]string{"message_type", "peer_id"},
|
||||
@@ -204,7 +204,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.p2pMessageLatency = promauto.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "bzzz_p2p_message_latency_seconds",
|
||||
Name: "chorus_p2p_message_latency_seconds",
|
||||
Help: "P2P message round-trip latency",
|
||||
Buckets: config.LatencyBuckets,
|
||||
},
|
||||
@@ -214,7 +214,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// DHT metrics
|
||||
m.dhtPutOperations = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_dht_put_operations_total",
|
||||
Name: "chorus_dht_put_operations_total",
|
||||
Help: "Total number of DHT put operations",
|
||||
},
|
||||
[]string{"status"},
|
||||
@@ -222,7 +222,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.dhtGetOperations = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_dht_get_operations_total",
|
||||
Name: "chorus_dht_get_operations_total",
|
||||
Help: "Total number of DHT get operations",
|
||||
},
|
||||
[]string{"status"},
|
||||
@@ -230,7 +230,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.dhtOperationLatency = promauto.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "bzzz_dht_operation_latency_seconds",
|
||||
Name: "chorus_dht_operation_latency_seconds",
|
||||
Help: "DHT operation latency",
|
||||
Buckets: config.LatencyBuckets,
|
||||
},
|
||||
@@ -239,21 +239,21 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.dhtProviderRecords = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_dht_provider_records",
|
||||
Name: "chorus_dht_provider_records",
|
||||
Help: "Number of DHT provider records",
|
||||
},
|
||||
)
|
||||
|
||||
m.dhtContentKeys = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_dht_content_keys",
|
||||
Name: "chorus_dht_content_keys",
|
||||
Help: "Number of DHT content keys",
|
||||
},
|
||||
)
|
||||
|
||||
m.dhtReplicationFactor = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_dht_replication_factor",
|
||||
Name: "chorus_dht_replication_factor",
|
||||
Help: "DHT replication factor by key",
|
||||
},
|
||||
[]string{"key_hash"},
|
||||
@@ -262,14 +262,14 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// PubSub metrics
|
||||
m.pubsubTopics = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_pubsub_topics",
|
||||
Name: "chorus_pubsub_topics",
|
||||
Help: "Number of active PubSub topics",
|
||||
},
|
||||
)
|
||||
|
||||
m.pubsubMessages = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_pubsub_messages_total",
|
||||
Name: "chorus_pubsub_messages_total",
|
||||
Help: "Total number of PubSub messages",
|
||||
},
|
||||
[]string{"topic", "direction", "message_type"},
|
||||
@@ -277,7 +277,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.pubsubMessageLatency = promauto.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "bzzz_pubsub_message_latency_seconds",
|
||||
Name: "chorus_pubsub_message_latency_seconds",
|
||||
Help: "PubSub message latency",
|
||||
Buckets: config.LatencyBuckets,
|
||||
},
|
||||
@@ -287,14 +287,14 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// Election metrics
|
||||
m.electionTerm = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_election_term",
|
||||
Name: "chorus_election_term",
|
||||
Help: "Current election term",
|
||||
},
|
||||
)
|
||||
|
||||
m.electionState = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_election_state",
|
||||
Name: "chorus_election_state",
|
||||
Help: "Current election state (1 for active state)",
|
||||
},
|
||||
[]string{"state"},
|
||||
@@ -302,21 +302,21 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.heartbeatsSent = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_heartbeats_sent_total",
|
||||
Name: "chorus_heartbeats_sent_total",
|
||||
Help: "Total number of heartbeats sent",
|
||||
},
|
||||
)
|
||||
|
||||
m.heartbeatsReceived = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_heartbeats_received_total",
|
||||
Name: "chorus_heartbeats_received_total",
|
||||
Help: "Total number of heartbeats received",
|
||||
},
|
||||
)
|
||||
|
||||
m.leadershipChanges = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_leadership_changes_total",
|
||||
Name: "chorus_leadership_changes_total",
|
||||
Help: "Total number of leadership changes",
|
||||
},
|
||||
)
|
||||
@@ -324,7 +324,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// Health metrics
|
||||
m.healthChecksPassed = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_health_checks_passed_total",
|
||||
Name: "chorus_health_checks_passed_total",
|
||||
Help: "Total number of health checks passed",
|
||||
},
|
||||
[]string{"check_name"},
|
||||
@@ -332,7 +332,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.healthChecksFailed = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_health_checks_failed_total",
|
||||
Name: "chorus_health_checks_failed_total",
|
||||
Help: "Total number of health checks failed",
|
||||
},
|
||||
[]string{"check_name", "reason"},
|
||||
@@ -340,14 +340,14 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.systemHealthScore = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_system_health_score",
|
||||
Name: "chorus_system_health_score",
|
||||
Help: "Overall system health score (0-1)",
|
||||
},
|
||||
)
|
||||
|
||||
m.componentHealthScore = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_component_health_score",
|
||||
Name: "chorus_component_health_score",
|
||||
Help: "Component health score (0-1)",
|
||||
},
|
||||
[]string{"component"},
|
||||
@@ -356,21 +356,21 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// Task metrics
|
||||
m.tasksActive = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_tasks_active",
|
||||
Name: "chorus_tasks_active",
|
||||
Help: "Number of active tasks",
|
||||
},
|
||||
)
|
||||
|
||||
m.tasksQueued = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_tasks_queued",
|
||||
Name: "chorus_tasks_queued",
|
||||
Help: "Number of queued tasks",
|
||||
},
|
||||
)
|
||||
|
||||
m.tasksCompleted = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_tasks_completed_total",
|
||||
Name: "chorus_tasks_completed_total",
|
||||
Help: "Total number of completed tasks",
|
||||
},
|
||||
[]string{"status", "task_type"},
|
||||
@@ -378,7 +378,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.taskDuration = promauto.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "bzzz_task_duration_seconds",
|
||||
Name: "chorus_task_duration_seconds",
|
||||
Help: "Task execution duration",
|
||||
Buckets: config.LatencyBuckets,
|
||||
},
|
||||
@@ -388,7 +388,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// SLURP metrics
|
||||
m.slurpGenerated = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_slurp_contexts_generated_total",
|
||||
Name: "chorus_slurp_contexts_generated_total",
|
||||
Help: "Total number of contexts generated by SLURP",
|
||||
},
|
||||
[]string{"role", "status"},
|
||||
@@ -396,7 +396,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.slurpGenerationTime = promauto.NewHistogram(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "bzzz_slurp_generation_time_seconds",
|
||||
Name: "chorus_slurp_generation_time_seconds",
|
||||
Help: "SLURP context generation time",
|
||||
Buckets: []float64{0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 30.0, 60.0, 120.0},
|
||||
},
|
||||
@@ -404,7 +404,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.slurpQueueLength = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_slurp_queue_length",
|
||||
Name: "chorus_slurp_queue_length",
|
||||
Help: "Length of SLURP generation queue",
|
||||
},
|
||||
)
|
||||
@@ -412,7 +412,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// UCXI metrics
|
||||
m.ucxiRequests = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_ucxi_requests_total",
|
||||
Name: "chorus_ucxi_requests_total",
|
||||
Help: "Total number of UCXI requests",
|
||||
},
|
||||
[]string{"method", "status"},
|
||||
@@ -420,7 +420,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.ucxiResolutionLatency = promauto.NewHistogram(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "bzzz_ucxi_resolution_latency_seconds",
|
||||
Name: "chorus_ucxi_resolution_latency_seconds",
|
||||
Help: "UCXI address resolution latency",
|
||||
Buckets: config.LatencyBuckets,
|
||||
},
|
||||
@@ -429,21 +429,21 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// Resource metrics
|
||||
m.cpuUsage = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_cpu_usage_ratio",
|
||||
Name: "chorus_cpu_usage_ratio",
|
||||
Help: "CPU usage ratio (0-1)",
|
||||
},
|
||||
)
|
||||
|
||||
m.memoryUsage = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_memory_usage_bytes",
|
||||
Name: "chorus_memory_usage_bytes",
|
||||
Help: "Memory usage in bytes",
|
||||
},
|
||||
)
|
||||
|
||||
m.diskUsage = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_disk_usage_ratio",
|
||||
Name: "chorus_disk_usage_ratio",
|
||||
Help: "Disk usage ratio (0-1)",
|
||||
},
|
||||
[]string{"mount_point"},
|
||||
@@ -451,7 +451,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.goroutines = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "bzzz_goroutines",
|
||||
Name: "chorus_goroutines",
|
||||
Help: "Number of goroutines",
|
||||
},
|
||||
)
|
||||
@@ -459,7 +459,7 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
// Error metrics
|
||||
m.errors = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_errors_total",
|
||||
Name: "chorus_errors_total",
|
||||
Help: "Total number of errors",
|
||||
},
|
||||
[]string{"component", "error_type"},
|
||||
@@ -467,20 +467,20 @@ func (m *BZZZMetrics) initializeMetrics(config *MetricsConfig) {
|
||||
|
||||
m.panics = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "bzzz_panics_total",
|
||||
Name: "chorus_panics_total",
|
||||
Help: "Total number of panics",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// registerMetrics registers all metrics with the registry
|
||||
func (m *BZZZMetrics) registerMetrics() {
|
||||
func (m *CHORUSMetrics) registerMetrics() {
|
||||
// All metrics are auto-registered with the default registry
|
||||
// For custom registry, we would need to register manually
|
||||
}
|
||||
|
||||
// StartServer starts the Prometheus metrics HTTP server
|
||||
func (m *BZZZMetrics) StartServer(config *MetricsConfig) error {
|
||||
func (m *CHORUSMetrics) StartServer(config *MetricsConfig) error {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// Use custom registry
|
||||
@@ -511,7 +511,7 @@ func (m *BZZZMetrics) StartServer(config *MetricsConfig) error {
|
||||
}
|
||||
|
||||
// StopServer stops the metrics HTTP server
|
||||
func (m *BZZZMetrics) StopServer() error {
|
||||
func (m *CHORUSMetrics) StopServer() error {
|
||||
if m.httpServer != nil {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
@@ -522,69 +522,69 @@ func (m *BZZZMetrics) StopServer() error {
|
||||
|
||||
// P2P Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) SetConnectedPeers(count int) {
|
||||
func (m *CHORUSMetrics) SetConnectedPeers(count int) {
|
||||
m.p2pConnectedPeers.Set(float64(count))
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementMessagesSent(messageType, peerID string) {
|
||||
func (m *CHORUSMetrics) IncrementMessagesSent(messageType, peerID string) {
|
||||
m.p2pMessagesSent.WithLabelValues(messageType, peerID).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementMessagesReceived(messageType, peerID string) {
|
||||
func (m *CHORUSMetrics) IncrementMessagesReceived(messageType, peerID string) {
|
||||
m.p2pMessagesReceived.WithLabelValues(messageType, peerID).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) ObserveMessageLatency(messageType string, latency time.Duration) {
|
||||
func (m *CHORUSMetrics) ObserveMessageLatency(messageType string, latency time.Duration) {
|
||||
m.p2pMessageLatency.WithLabelValues(messageType).Observe(latency.Seconds())
|
||||
}
|
||||
|
||||
// DHT Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) IncrementDHTPutOperations(status string) {
|
||||
func (m *CHORUSMetrics) IncrementDHTPutOperations(status string) {
|
||||
m.dhtPutOperations.WithLabelValues(status).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementDHTGetOperations(status string) {
|
||||
func (m *CHORUSMetrics) IncrementDHTGetOperations(status string) {
|
||||
m.dhtGetOperations.WithLabelValues(status).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) ObserveDHTOperationLatency(operation, status string, latency time.Duration) {
|
||||
func (m *CHORUSMetrics) ObserveDHTOperationLatency(operation, status string, latency time.Duration) {
|
||||
m.dhtOperationLatency.WithLabelValues(operation, status).Observe(latency.Seconds())
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetDHTProviderRecords(count int) {
|
||||
func (m *CHORUSMetrics) SetDHTProviderRecords(count int) {
|
||||
m.dhtProviderRecords.Set(float64(count))
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetDHTContentKeys(count int) {
|
||||
func (m *CHORUSMetrics) SetDHTContentKeys(count int) {
|
||||
m.dhtContentKeys.Set(float64(count))
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetDHTReplicationFactor(keyHash string, factor float64) {
|
||||
func (m *CHORUSMetrics) SetDHTReplicationFactor(keyHash string, factor float64) {
|
||||
m.dhtReplicationFactor.WithLabelValues(keyHash).Set(factor)
|
||||
}
|
||||
|
||||
// PubSub Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) SetPubSubTopics(count int) {
|
||||
func (m *CHORUSMetrics) SetPubSubTopics(count int) {
|
||||
m.pubsubTopics.Set(float64(count))
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementPubSubMessages(topic, direction, messageType string) {
|
||||
func (m *CHORUSMetrics) IncrementPubSubMessages(topic, direction, messageType string) {
|
||||
m.pubsubMessages.WithLabelValues(topic, direction, messageType).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) ObservePubSubMessageLatency(topic string, latency time.Duration) {
|
||||
func (m *CHORUSMetrics) ObservePubSubMessageLatency(topic string, latency time.Duration) {
|
||||
m.pubsubMessageLatency.WithLabelValues(topic).Observe(latency.Seconds())
|
||||
}
|
||||
|
||||
// Election Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) SetElectionTerm(term int) {
|
||||
func (m *CHORUSMetrics) SetElectionTerm(term int) {
|
||||
m.electionTerm.Set(float64(term))
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetElectionState(state string) {
|
||||
func (m *CHORUSMetrics) SetElectionState(state string) {
|
||||
// Reset all state gauges
|
||||
states := []string{"idle", "discovering", "electing", "reconstructing", "complete"}
|
||||
for _, s := range states {
|
||||
@@ -594,118 +594,118 @@ func (m *BZZZMetrics) SetElectionState(state string) {
|
||||
m.electionState.WithLabelValues(state).Set(1)
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementHeartbeatsSent() {
|
||||
func (m *CHORUSMetrics) IncrementHeartbeatsSent() {
|
||||
m.heartbeatsSent.Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementHeartbeatsReceived() {
|
||||
func (m *CHORUSMetrics) IncrementHeartbeatsReceived() {
|
||||
m.heartbeatsReceived.Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementLeadershipChanges() {
|
||||
func (m *CHORUSMetrics) IncrementLeadershipChanges() {
|
||||
m.leadershipChanges.Inc()
|
||||
}
|
||||
|
||||
// Health Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) IncrementHealthCheckPassed(checkName string) {
|
||||
func (m *CHORUSMetrics) IncrementHealthCheckPassed(checkName string) {
|
||||
m.healthChecksPassed.WithLabelValues(checkName).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementHealthCheckFailed(checkName, reason string) {
|
||||
func (m *CHORUSMetrics) IncrementHealthCheckFailed(checkName, reason string) {
|
||||
m.healthChecksFailed.WithLabelValues(checkName, reason).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetSystemHealthScore(score float64) {
|
||||
func (m *CHORUSMetrics) SetSystemHealthScore(score float64) {
|
||||
m.systemHealthScore.Set(score)
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetComponentHealthScore(component string, score float64) {
|
||||
func (m *CHORUSMetrics) SetComponentHealthScore(component string, score float64) {
|
||||
m.componentHealthScore.WithLabelValues(component).Set(score)
|
||||
}
|
||||
|
||||
// Task Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) SetActiveTasks(count int) {
|
||||
func (m *CHORUSMetrics) SetActiveTasks(count int) {
|
||||
m.tasksActive.Set(float64(count))
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetQueuedTasks(count int) {
|
||||
func (m *CHORUSMetrics) SetQueuedTasks(count int) {
|
||||
m.tasksQueued.Set(float64(count))
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementTasksCompleted(status, taskType string) {
|
||||
func (m *CHORUSMetrics) IncrementTasksCompleted(status, taskType string) {
|
||||
m.tasksCompleted.WithLabelValues(status, taskType).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) ObserveTaskDuration(taskType, status string, duration time.Duration) {
|
||||
func (m *CHORUSMetrics) ObserveTaskDuration(taskType, status string, duration time.Duration) {
|
||||
m.taskDuration.WithLabelValues(taskType, status).Observe(duration.Seconds())
|
||||
}
|
||||
|
||||
// SLURP Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) IncrementSLURPGenerated(role, status string) {
|
||||
func (m *CHORUSMetrics) IncrementSLURPGenerated(role, status string) {
|
||||
m.slurpGenerated.WithLabelValues(role, status).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) ObserveSLURPGenerationTime(duration time.Duration) {
|
||||
func (m *CHORUSMetrics) ObserveSLURPGenerationTime(duration time.Duration) {
|
||||
m.slurpGenerationTime.Observe(duration.Seconds())
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetSLURPQueueLength(length int) {
|
||||
func (m *CHORUSMetrics) SetSLURPQueueLength(length int) {
|
||||
m.slurpQueueLength.Set(float64(length))
|
||||
}
|
||||
|
||||
// UCXI Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) IncrementUCXIRequests(method, status string) {
|
||||
func (m *CHORUSMetrics) IncrementUCXIRequests(method, status string) {
|
||||
m.ucxiRequests.WithLabelValues(method, status).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) ObserveUCXIResolutionLatency(latency time.Duration) {
|
||||
func (m *CHORUSMetrics) ObserveUCXIResolutionLatency(latency time.Duration) {
|
||||
m.ucxiResolutionLatency.Observe(latency.Seconds())
|
||||
}
|
||||
|
||||
// Resource Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) SetCPUUsage(usage float64) {
|
||||
func (m *CHORUSMetrics) SetCPUUsage(usage float64) {
|
||||
m.cpuUsage.Set(usage)
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetMemoryUsage(usage float64) {
|
||||
func (m *CHORUSMetrics) SetMemoryUsage(usage float64) {
|
||||
m.memoryUsage.Set(usage)
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetDiskUsage(mountPoint string, usage float64) {
|
||||
func (m *CHORUSMetrics) SetDiskUsage(mountPoint string, usage float64) {
|
||||
m.diskUsage.WithLabelValues(mountPoint).Set(usage)
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) SetGoroutines(count int) {
|
||||
func (m *CHORUSMetrics) SetGoroutines(count int) {
|
||||
m.goroutines.Set(float64(count))
|
||||
}
|
||||
|
||||
// Error Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) IncrementErrors(component, errorType string) {
|
||||
func (m *CHORUSMetrics) IncrementErrors(component, errorType string) {
|
||||
m.errors.WithLabelValues(component, errorType).Inc()
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) IncrementPanics() {
|
||||
func (m *CHORUSMetrics) IncrementPanics() {
|
||||
m.panics.Inc()
|
||||
}
|
||||
|
||||
// System Metrics Methods
|
||||
|
||||
func (m *BZZZMetrics) UpdateSystemInfo(nodeID, version, goVersion, cluster, environment string) {
|
||||
func (m *CHORUSMetrics) UpdateSystemInfo(nodeID, version, goVersion, cluster, environment string) {
|
||||
m.systemInfo.WithLabelValues(nodeID, version, goVersion, cluster, environment).Set(1)
|
||||
}
|
||||
|
||||
func (m *BZZZMetrics) UpdateUptime() {
|
||||
func (m *CHORUSMetrics) UpdateUptime() {
|
||||
m.uptime.Set(time.Since(m.startTime).Seconds())
|
||||
}
|
||||
|
||||
// CollectMetrics starts background metric collection
|
||||
func (m *BZZZMetrics) CollectMetrics(config *MetricsConfig) {
|
||||
func (m *CHORUSMetrics) CollectMetrics(config *MetricsConfig) {
|
||||
systemTicker := time.NewTicker(config.SystemMetricsInterval)
|
||||
resourceTicker := time.NewTicker(config.ResourceMetricsInterval)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user