fix: align group management APIs

This commit is contained in:
richjohnrambo
2026-09-13 16:03:55 +08:00
parent f1279ac607
commit a9afc6ff6a
34 changed files with 1381 additions and 639 deletions
+33 -1
View File
@@ -28,6 +28,17 @@ var (
Buckets: []float64{0.001, 0.003, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5},
}, []string{"driver", "operation", "status"})
RealtimeFanoutEventsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "realtime_fanout_events_total",
Help: "Total number of realtime fanout events by stage, kind, target type, and status.",
}, []string{"stage", "kind", "target_type", "status"})
RealtimeFanoutDeliveryDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Name: "realtime_fanout_delivery_duration_seconds",
Help: "Realtime fanout delivery age measured from message timestamp to local dispatch.",
Buckets: []float64{0.001, 0.003, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10},
}, []string{"kind", "target_type"})
WSConnectionsActive = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Name: "ws_connections_active",
Help: "Current active WebSocket connections.",
@@ -37,7 +48,8 @@ var (
)
func init() {
Registry.MustRegister(WSConnectionsActive, HTTPRequestsTotal, HTTPRequestDuration, DBQueryDuration)
Registry.MustRegister(WSConnectionsActive, HTTPRequestsTotal, HTTPRequestDuration, DBQueryDuration,
RealtimeFanoutEventsTotal, RealtimeFanoutDeliveryDuration)
}
func ObserveDB(driverName, operation string, started time.Time, err error) {
@@ -48,6 +60,26 @@ func ObserveDB(driverName, operation string, started time.Time, err error) {
DBQueryDuration.WithLabelValues(driverName, operation, status).Observe(time.Since(started).Seconds())
}
func IncRealtimeFanout(stage, kind, targetType, status string) {
RealtimeFanoutEventsTotal.WithLabelValues(normalizeLabel(stage), normalizeLabel(kind),
normalizeLabel(targetType), normalizeLabel(status)).Inc()
}
func ObserveRealtimeFanoutDelivery(kind, targetType string, timestamp time.Time) {
if timestamp.IsZero() {
return
}
RealtimeFanoutDeliveryDuration.WithLabelValues(normalizeLabel(kind), normalizeLabel(targetType)).
Observe(time.Since(timestamp).Seconds())
}
func normalizeLabel(value string) string {
if value == "" {
return "unknown"
}
return value
}
func expvarIntValue(name string) int64 {
value := expvar.Get(name)
if value == nil {