MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / RegisterNodeHubMetrics

Function RegisterNodeHubMetrics

internal/serverapi/nodehub_metrics.go:19–32  ·  view source on GitHub ↗

RegisterNodeHubMetrics 在 protected mux 上注册 GET /v1/system/nodehub/metrics。 调用方负责把 mux 包在 admin auth middleware 中(与 /v1/system/info 一致)。

(mux *http.ServeMux, hub *nodehub.Hub)

Source from the content-addressed store, hash-verified

17// RegisterNodeHubMetrics 在 protected mux 上注册 GET /v1/system/nodehub/metrics。
18// 调用方负责把 mux 包在 admin auth middleware 中(与 /v1/system/info 一致)。
19func RegisterNodeHubMetrics(mux *http.ServeMux, hub *nodehub.Hub) {
20 if hub == nil {
21 return
22 }
23 mux.HandleFunc("GET /v1/system/nodehub/metrics", func(w http.ResponseWriter, r *http.Request) {
24 snap := hub.Snapshot()
25 success, failure := EnrollMetrics()
26 writeJSON(w, http.StatusOK, nodeHubMetricsResponse{
27 Snapshot: snap,
28 EnrollSuccessTotal: success,
29 EnrollFailureTotal: failure,
30 })
31 })
32}

Callers 3

RunFunction · 0.92

Calls 3

EnrollMetricsFunction · 0.85
SnapshotMethod · 0.80
writeJSONFunction · 0.70

Tested by 2