fix prometheus metrics gone after route changes

This commit is contained in:
yusing
2024-12-18 00:54:04 +08:00
parent 4ae3d5344c
commit 34858a1ba0
5 changed files with 24 additions and 8 deletions

View File

@@ -4,7 +4,6 @@ import (
"sync/atomic"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/yusing/go-proxy/internal/common"
"github.com/yusing/go-proxy/internal/docker/idlewatcher/types"
E "github.com/yusing/go-proxy/internal/error"
@@ -86,7 +85,7 @@ func (w *Watcher) Start(routeSubTask *task.Task) E.Error {
w.task.OnCancel("stop route and cleanup", func() {
routeSubTask.Parent().Finish(w.task.FinishCause())
if w.metric != nil {
prometheus.Unregister(w.metric)
w.metric.Reset()
}
})
return nil