chore(prometheus): drop service health metrics

This commit is contained in:
yusing 2025-04-07 12:51:20 +08:00
parent 5da9dd6082
commit 111d767d46
3 changed files with 1 additions and 41 deletions

View file

@ -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

View file

@ -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"),
}
}

View file

@ -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
}