Skip to content

Commit

Permalink
feat: handle review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Oct 3, 2023
1 parent 9c3c5d3 commit f50b7a5
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions cmd/collectors/rest/plugins/netroute/netroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,23 @@ func (n *NetRoute) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, err
names := interfacesList.Get("name").Array()
address := interfacesList.Get("address").Array()

if names != nil && address != nil {
if len(names) == len(address) {
for i, name := range names {
index := strings.Join([]string{cluster, strconv.Itoa(count)}, "_")
interfaceInstance, err := n.data.NewInstance(index)
if err != nil {
n.Logger.Error().Err(err).Str("add instance failed for instance key", key).Send()
return nil, err
}

for _, l := range instanceLabels {
interfaceInstance.SetLabel(l, instance.GetLabel(l))
}
interfaceInstance.SetLabel("index", index)
interfaceInstance.SetLabel("address", address[i].String())
interfaceInstance.SetLabel("name", name.String())
interfaceInstance.SetLabel("route_uuid", routeID)
count++
if len(names) == len(address) {
for i, name := range names {
index := strings.Join([]string{cluster, strconv.Itoa(count)}, "_")
interfaceInstance, err := n.data.NewInstance(index)
if err != nil {
n.Logger.Error().Err(err).Str("add instance failed for instance key", key).Send()
return nil, err
}

for _, l := range instanceLabels {
interfaceInstance.SetLabel(l, instance.GetLabel(l))
}
interfaceInstance.SetLabel("index", index)
interfaceInstance.SetLabel("address", address[i].String())
interfaceInstance.SetLabel("name", name.String())
interfaceInstance.SetLabel("route_uuid", routeID)
count++
}
}
}
Expand Down

0 comments on commit f50b7a5

Please sign in to comment.