From 111d767d4679be35cd8cf093691dfd749e7fe664 Mon Sep 17 00:00:00 2001 From: yusing Date: Mon, 7 Apr 2025 12:51:20 +0800 Subject: [PATCH] chore(prometheus): drop service health metrics --- internal/idlewatcher/waker.go | 9 -------- internal/metrics/metrics.go | 24 +--------------------- internal/watcher/health/monitor/monitor.go | 9 -------- 3 files changed, 1 insertion(+), 41 deletions(-) diff --git a/internal/idlewatcher/waker.go b/internal/idlewatcher/waker.go index 0571f664..1787cd9f 100644 --- a/internal/idlewatcher/waker.go +++ b/internal/idlewatcher/waker.go @@ -5,7 +5,6 @@ import ( "github.com/yusing/go-proxy/internal/gperr" idlewatcher "github.com/yusing/go-proxy/internal/idlewatcher/types" - "github.com/yusing/go-proxy/internal/metrics" "github.com/yusing/go-proxy/internal/net/gphttp/reverseproxy" net "github.com/yusing/go-proxy/internal/net/types" route "github.com/yusing/go-proxy/internal/route/types" @@ -23,7 +22,6 @@ type ( rp *reverseproxy.ReverseProxy stream net.Stream hc health.HealthChecker - metric *metrics.Gauge } ) @@ -74,9 +72,6 @@ func NewStreamWaker(parent task.Parent, route route.Route, stream net.Stream) (W func (w *Watcher) Start(parent task.Parent) gperr.Error { w.task.OnCancel("route_cleanup", func() { parent.Finish(w.task.FinishCause()) - if w.metric != nil { - w.metric.Reset() - } }) return nil } @@ -138,10 +133,6 @@ func (w *Watcher) checkUpdateState() (ready bool, err error) { return false, nil } - if w.metric != nil { - defer w.metric.Set(float64(w.Status())) - } - // the new container info not yet updated if w.hc.URL().Host == "" { return false, nil diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 4cabe2f7..0088c7ef 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -15,16 +15,9 @@ type ( HTTP5xx *Counter HTTPReqElapsed *Gauge } - - ServiceMetrics struct { - HealthStatus *Gauge - } ) -var ( - rm RouteMetrics - sm ServiceMetrics -) +var rm RouteMetrics const ( routerNamespace = "router" @@ -37,10 +30,6 @@ func GetRouteMetrics() *RouteMetrics { return &rm } -func GetServiceMetrics() *ServiceMetrics { - return &sm -} - func (rm *RouteMetrics) UnregisterService(service string) { lbls := &HTTPRouteMetricLabels{Service: service} rm.HTTP2xx3xx.Delete(lbls) @@ -54,7 +43,6 @@ func init() { return } initRouteMetrics() - initServiceMetrics() } func initRouteMetrics() { @@ -93,13 +81,3 @@ func initRouteMetrics() { }, lbls...), } } - -func initServiceMetrics() { - sm = ServiceMetrics{ - HealthStatus: NewGauge(prometheus.GaugeOpts{ - Namespace: serviceNamespace, - Name: "health_status", - Help: "The health status of the router by service", - }, "service"), - } -} diff --git a/internal/watcher/health/monitor/monitor.go b/internal/watcher/health/monitor/monitor.go index 7fa3420b..461f3192 100644 --- a/internal/watcher/health/monitor/monitor.go +++ b/internal/watcher/health/monitor/monitor.go @@ -8,7 +8,6 @@ import ( "github.com/yusing/go-proxy/internal/gperr" "github.com/yusing/go-proxy/internal/logging" - "github.com/yusing/go-proxy/internal/metrics" "github.com/yusing/go-proxy/internal/net/types" "github.com/yusing/go-proxy/internal/notif" "github.com/yusing/go-proxy/internal/task" @@ -30,8 +29,6 @@ type ( checkHealth HealthCheckFunc startTime time.Time - metric *metrics.Gauge - task *task.Task } ) @@ -72,9 +69,6 @@ func (mon *monitor) Start(parent task.Parent) gperr.Error { if mon.status.Load() != health.StatusError { mon.status.Store(health.StatusUnknown) } - if mon.metric != nil { - mon.metric.Reset() - } mon.task.Finish(nil) }() @@ -230,9 +224,6 @@ func (mon *monitor) checkUpdateHealth() error { }) } } - if mon.metric != nil { - mon.metric.Set(float64(status)) - } return nil }