api: remove service health from prometheus, implement godoxy metrics

This commit is contained in:
yusing
2025-02-12 05:30:34 +08:00
parent 72dc76ec74
commit c807b30c8f
21 changed files with 531 additions and 152 deletions

View File

@@ -15,6 +15,7 @@ import (
E "github.com/yusing/go-proxy/internal/error"
"github.com/yusing/go-proxy/internal/logging"
"github.com/yusing/go-proxy/internal/logging/memlogger"
"github.com/yusing/go-proxy/internal/metrics/systeminfo"
"github.com/yusing/go-proxy/internal/task"
"github.com/yusing/go-proxy/internal/utils/strutils"
)
@@ -49,7 +50,7 @@ func NewAgentHandler() http.Handler {
})
mux.HandleMethods("GET", agent.EndpointHealth, CheckHealth)
mux.HandleMethods("GET", agent.EndpointLogs, memlogger.LogsWS(nil))
mux.HandleMethods("GET", agent.EndpointSystemInfo, SystemInfo)
mux.HandleMethods("GET", agent.EndpointSystemInfo, systeminfo.Poller.ServeHTTP)
mux.ServeMux.HandleFunc("/", DockerSocketHandler())
return mux
}

View File

@@ -1,17 +0,0 @@
package handler
import (
"net/http"
"github.com/yusing/go-proxy/internal/api/v1/utils"
"github.com/yusing/go-proxy/internal/metrics"
)
func SystemInfo(w http.ResponseWriter, r *http.Request) {
info, err := metrics.GetSystemInfo(r.Context())
if err != nil {
utils.HandleErr(w, r, err)
return
}
utils.RespondJSON(w, r, info)
}