Skip to content

Commit

Permalink
chore: add check summary in topology tree
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Nov 16, 2023
1 parent 5976ee6 commit 7284678
Show file tree
Hide file tree
Showing 16 changed files with 1,300 additions and 1,128 deletions.
4 changes: 2 additions & 2 deletions models/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (c *Component) Summarize() types.Summary {
var s types.Summary
s.Incidents = c.Summary.Incidents
s.Insights = c.Summary.Insights
s.Checks = c.Summary.Checks

if c.Components == nil {
switch c.Status {
Expand All @@ -113,8 +114,7 @@ func (c *Component) Summarize() types.Summary {
case types.ComponentStatusInfo:
s.Info++
}
s.Incidents = c.Summary.Incidents
s.Insights = c.Summary.Insights

s.SetProcessed(true)
return s
}
Expand Down
5 changes: 3 additions & 2 deletions query/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ func createComponentTree(params TopologyOptions, components models.Components) [
// TODO: Try https://stackoverflow.com/questions/30101603/merging-concatenating-jsonb-columns-in-query
c.Summary.Incidents = c.Incidents
c.Summary.Insights = c.Analysis
c.Analysis = nil
c.Incidents = nil
c.Summary.Checks = c.Checks

c.Analysis, c.Incidents, c.Checks = nil, nil, nil

if c.ParentId != nil {
if _, exists := compChildrenMap[c.ParentId.String()]; exists {
Expand Down
146 changes: 76 additions & 70 deletions tests/fixtures/expectations/topology_child_tree.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,79 @@
{
"components": [
{
"agent_id": "00000000-0000-0000-0000-000000000000",
"children": [
"018681ff-80ed-d10d-21ef-c74f152b085b",
"018681ff-b6c1-a14d-2fd4-8c7dac94cddd"
],
"components": [
"components": [
{
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/logistics-api-574dc95b5d-mp64w",
"icon": "icon-kubernetes-pod",
"id": "018681ff-80ed-d10d-21ef-c74f152b085b",
"is_leaf": false,
"name": "logistics-api-574dc95b5d-mp64w",
"parent_id": "018681ff-559f-7183-19d1-7d898b4e1413",
"parents": [
"018681fe-f5aa-37e9-83f7-47b5b0232d5e"
],
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413",
"status": "healthy",
"summary": {
"healthy": 1
},
"tooltip": "Logistic API Pod",
"type": "KubernetesPod"
},
{
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/logistics-ui-676b85b87c-tjjcp",
"icon": "icon-kubernetes-pod",
"id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd",
"is_leaf": false,
"name": "logistics-ui-676b85b87c-tjjcp",
"parent_id": "018681ff-559f-7183-19d1-7d898b4e1413",
"parents": [
"018681fe-f5aa-37e9-83f7-47b5b0232d5e"
],
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413",
"status": "healthy",
"summary": {
"healthy": 1
},
"tooltip": "Logistic UI Pod",
"type": "KubernetesPod"
"id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e",
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/node-a",
"parent_id": "018681fe-b27e-7627-72c2-ad18e93f72f4",
"name": "node-a",
"status": "healthy",
"tooltip": "Node A",
"icon": "icon-kubernetes-node",
"type": "KubernetesNode",
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681fe-b27e-7627-72c2-ad18e93f72f4",
"summary": {
"healthy": 2
},
"is_leaf": false,
"created_at": "2023-01-01T05:29:00+05:30",
"updated_at": "2023-01-01T05:29:00+05:30",
"components": [
{
"id": "018681ff-80ed-d10d-21ef-c74f152b085b",
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/logistics-api-574dc95b5d-mp64w",
"parent_id": "018681ff-559f-7183-19d1-7d898b4e1413",
"name": "logistics-api-574dc95b5d-mp64w",
"status": "healthy",
"tooltip": "Logistic API Pod",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413",
"summary": {
"healthy": 1
},
"is_leaf": false,
"created_at": "2023-01-01T05:29:00+05:30",
"updated_at": "2023-01-01T05:29:00+05:30",
"parents": [
"018681fe-f5aa-37e9-83f7-47b5b0232d5e"
]
},
{
"id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd",
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/logistics-ui-676b85b87c-tjjcp",
"parent_id": "018681ff-559f-7183-19d1-7d898b4e1413",
"name": "logistics-ui-676b85b87c-tjjcp",
"status": "healthy",
"tooltip": "Logistic UI Pod",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413",
"summary": {
"healthy": 1
},
"is_leaf": false,
"created_at": "2023-01-01T05:29:00+05:30",
"updated_at": "2023-01-01T05:29:00+05:30",
"parents": [
"018681fe-f5aa-37e9-83f7-47b5b0232d5e"
]
}
],
"children": [
"018681ff-80ed-d10d-21ef-c74f152b085b",
"018681ff-b6c1-a14d-2fd4-8c7dac94cddd"
]
}
],
"external_id": "dummy/node-a",
"icon": "icon-kubernetes-node",
"id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e",
"is_leaf": false,
"name": "node-a",
"parent_id": "018681fe-b27e-7627-72c2-ad18e93f72f4",
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681fe-b27e-7627-72c2-ad18e93f72f4",
"status": "healthy",
"summary": {
"healthy": 2
},
"tooltip": "Node A",
"type": "KubernetesNode"
}
],
"healthStatuses": [
"healthy"
],
"tags": null,
"teams": [],
"types": [
"KubernetesNode",
"KubernetesPod"
]
}
],
"healthStatuses": [
"healthy"
],
"teams": [],
"tags": null,
"types": [
"KubernetesNode",
"KubernetesPod"
]
}
Loading

0 comments on commit 7284678

Please sign in to comment.