diff --git a/components/dashboard_metrics/component.go b/components/dashboard_metrics/component.go index 38deedc28..03ef46e55 100644 --- a/components/dashboard_metrics/component.go +++ b/components/dashboard_metrics/component.go @@ -75,15 +75,15 @@ func configure() error { routeGroup := deps.RestRouteManager.AddRoute("dashboard-metrics/v2") routeGroup.GET(RouteNodeInfoExtended, func(c echo.Context) error { - return httpserver.JSONResponse(c, http.StatusOK, nodeInfoExtended()) + return responseByHeader(c, nodeInfoExtended(), http.StatusOK) }) routeGroup.GET(RouteDatabaseSizes, func(c echo.Context) error { - return httpserver.JSONResponse(c, http.StatusOK, databaseSizesMetrics()) + return responseByHeader(c, databaseSizesMetrics(), http.StatusOK) }) routeGroup.GET(RouteGossipMetrics, func(c echo.Context) error { - return httpserver.JSONResponse(c, http.StatusOK, gossipMetrics()) + return responseByHeader(c, gossipMetrics(), http.StatusOK) }) return nil @@ -101,3 +101,7 @@ func run() error { return nil } + +func responseByHeader(c echo.Context, obj any, httpStatusCode ...int) error { + return httpserver.SendResponseByHeader(c, deps.Protocol.Engines.Main.Get().CommittedAPI(), obj, httpStatusCode...) +} diff --git a/components/dashboard_metrics/types.go b/components/dashboard_metrics/types.go index 9fcf07ef0..aacd49adf 100644 --- a/components/dashboard_metrics/types.go +++ b/components/dashboard_metrics/types.go @@ -2,26 +2,26 @@ package dashboardmetrics // NodeInfoExtended represents extended information about the node. type NodeInfoExtended struct { - Version string `json:"version"` - LatestVersion string `json:"latestVersion"` - Uptime int64 `json:"uptime"` - NodeID string `json:"nodeId"` - NodeAlias string `json:"nodeAlias"` - MemoryUsage int64 `json:"memUsage"` + Version string `serix:",lenPrefix=uint8"` + LatestVersion string `serix:",lenPrefix=uint8"` + Uptime int64 `serix:""` + NodeID string `serix:",lenPrefix=uint8"` + NodeAlias string `serix:",lenPrefix=uint8"` + MemoryUsage int64 `serix:""` } // DatabaseSizesMetric represents database size metrics. type DatabaseSizesMetric struct { - Permanent int64 `json:"permanent"` - Prunable int64 `json:"prunable"` - TxRetainer int64 `json:"txRetainer"` - Total int64 `json:"total"` - Time int64 `json:"ts"` + Permanent int64 `serix:""` + Prunable int64 `serix:""` + TxRetainer int64 `serix:""` + Total int64 `serix:""` + Time int64 `serix:""` } // GossipMetrics represents the metrics for blocks per second. type GossipMetrics struct { - Incoming uint32 `json:"incoming"` - New uint32 `json:"new"` - Outgoing uint32 `json:"outgoing"` + Incoming uint32 `serix:""` + New uint32 `serix:""` + Outgoing uint32 `serix:""` }