mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-24 21:14:02 +02:00
chore(prometheus): drop service health metrics
This commit is contained in:
parent
5da9dd6082
commit
111d767d46
3 changed files with 1 additions and 41 deletions
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
idlewatcher "github.com/yusing/go-proxy/internal/idlewatcher/types"
|
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"
|
"github.com/yusing/go-proxy/internal/net/gphttp/reverseproxy"
|
||||||
net "github.com/yusing/go-proxy/internal/net/types"
|
net "github.com/yusing/go-proxy/internal/net/types"
|
||||||
route "github.com/yusing/go-proxy/internal/route/types"
|
route "github.com/yusing/go-proxy/internal/route/types"
|
||||||
|
@ -23,7 +22,6 @@ type (
|
||||||
rp *reverseproxy.ReverseProxy
|
rp *reverseproxy.ReverseProxy
|
||||||
stream net.Stream
|
stream net.Stream
|
||||||
hc health.HealthChecker
|
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 {
|
func (w *Watcher) Start(parent task.Parent) gperr.Error {
|
||||||
w.task.OnCancel("route_cleanup", func() {
|
w.task.OnCancel("route_cleanup", func() {
|
||||||
parent.Finish(w.task.FinishCause())
|
parent.Finish(w.task.FinishCause())
|
||||||
if w.metric != nil {
|
|
||||||
w.metric.Reset()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -138,10 +133,6 @@ func (w *Watcher) checkUpdateState() (ready bool, err error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.metric != nil {
|
|
||||||
defer w.metric.Set(float64(w.Status()))
|
|
||||||
}
|
|
||||||
|
|
||||||
// the new container info not yet updated
|
// the new container info not yet updated
|
||||||
if w.hc.URL().Host == "" {
|
if w.hc.URL().Host == "" {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
|
@ -15,16 +15,9 @@ type (
|
||||||
HTTP5xx *Counter
|
HTTP5xx *Counter
|
||||||
HTTPReqElapsed *Gauge
|
HTTPReqElapsed *Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceMetrics struct {
|
|
||||||
HealthStatus *Gauge
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var rm RouteMetrics
|
||||||
rm RouteMetrics
|
|
||||||
sm ServiceMetrics
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
routerNamespace = "router"
|
routerNamespace = "router"
|
||||||
|
@ -37,10 +30,6 @@ func GetRouteMetrics() *RouteMetrics {
|
||||||
return &rm
|
return &rm
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetServiceMetrics() *ServiceMetrics {
|
|
||||||
return &sm
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rm *RouteMetrics) UnregisterService(service string) {
|
func (rm *RouteMetrics) UnregisterService(service string) {
|
||||||
lbls := &HTTPRouteMetricLabels{Service: service}
|
lbls := &HTTPRouteMetricLabels{Service: service}
|
||||||
rm.HTTP2xx3xx.Delete(lbls)
|
rm.HTTP2xx3xx.Delete(lbls)
|
||||||
|
@ -54,7 +43,6 @@ func init() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
initRouteMetrics()
|
initRouteMetrics()
|
||||||
initServiceMetrics()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initRouteMetrics() {
|
func initRouteMetrics() {
|
||||||
|
@ -93,13 +81,3 @@ func initRouteMetrics() {
|
||||||
}, lbls...),
|
}, lbls...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initServiceMetrics() {
|
|
||||||
sm = ServiceMetrics{
|
|
||||||
HealthStatus: NewGauge(prometheus.GaugeOpts{
|
|
||||||
Namespace: serviceNamespace,
|
|
||||||
Name: "health_status",
|
|
||||||
Help: "The health status of the router by service",
|
|
||||||
}, "service"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"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/net/types"
|
||||||
"github.com/yusing/go-proxy/internal/notif"
|
"github.com/yusing/go-proxy/internal/notif"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
|
@ -30,8 +29,6 @@ type (
|
||||||
checkHealth HealthCheckFunc
|
checkHealth HealthCheckFunc
|
||||||
startTime time.Time
|
startTime time.Time
|
||||||
|
|
||||||
metric *metrics.Gauge
|
|
||||||
|
|
||||||
task *task.Task
|
task *task.Task
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -72,9 +69,6 @@ func (mon *monitor) Start(parent task.Parent) gperr.Error {
|
||||||
if mon.status.Load() != health.StatusError {
|
if mon.status.Load() != health.StatusError {
|
||||||
mon.status.Store(health.StatusUnknown)
|
mon.status.Store(health.StatusUnknown)
|
||||||
}
|
}
|
||||||
if mon.metric != nil {
|
|
||||||
mon.metric.Reset()
|
|
||||||
}
|
|
||||||
mon.task.Finish(nil)
|
mon.task.Finish(nil)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -230,9 +224,6 @@ func (mon *monitor) checkUpdateHealth() error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if mon.metric != nil {
|
|
||||||
mon.metric.Set(float64(status))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue