Skip to content

Commit

Permalink
Fix dashboard metrics types
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Apr 19, 2024
1 parent 77a030b commit b8689a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
10 changes: 7 additions & 3 deletions components/dashboard_metrics/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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...)
}
28 changes: 14 additions & 14 deletions components/dashboard_metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:""`
}

0 comments on commit b8689a5

Please sign in to comment.