Skip to content

Commit

Permalink
feat: support comma separated aggrs in perf metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Sep 22, 2023
1 parent 7fafd2b commit 959b238
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 34 deletions.
11 changes: 9 additions & 2 deletions cmd/collectors/restperf/plugins/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error

re := regexp.MustCompile(`^(.*)__(\d{4})$`)

fgAggrMap := make(map[string]*set.Set)
flexgroupAggrsMap := make(map[string]*set.Set)
// volume_aggr_labels metric is deprecated now and will be removed later.
metricName := "labels"
Expand All @@ -69,10 +70,10 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error
fg, _ := cache.NewInstance(key)
fg.SetLabels(i.GetLabels().Copy())
fg.SetLabel("volume", match[1])
// Flexgroup don't show any aggregate, node
fg.SetLabel("aggr", "")
// Flexgroup don't show any node
fg.SetLabel("node", "")
fg.SetLabel(style, "flexgroup")
fgAggrMap[key] = set.New()
}

if volumeAggrmetric.GetInstance(key) == nil {
Expand All @@ -87,6 +88,7 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error
v.Logger.Error().Err(err).Str("metric", metricName).Msg("Unable to set value on metric")
}
}
fgAggrMap[key].Add(i.GetLabel("aggr"))
flexgroupAggrsMap[key].Add(i.GetLabel("aggr"))
i.SetLabel(style, "flexgroup_constituent")
i.SetExportable(false)
Expand Down Expand Up @@ -131,6 +133,11 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error
continue
}

// set aggrs label for fg, make sure the order of aggregate is same for each poll
aggrs := fgAggrMap[key].Values()
sort.Strings(aggrs)
fg.SetLabel("aggr", strings.Join(aggrs, ","))

for mkey, m := range data.GetMetrics() {

if !m.IsExportable() && m.GetType() != "float64" {
Expand Down
11 changes: 9 additions & 2 deletions cmd/collectors/zapiperf/plugins/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error
opsKeyPrefix := "temp_"
re := regexp.MustCompile(`^(.*)__(\d{4})$`)

fgAggrMap := make(map[string]*set.Set)
flexgroupAggrsMap := make(map[string]*set.Set)
// volume_aggr_labels metric is deprecated now and will be removed later.
metricName := "labels"
Expand Down Expand Up @@ -80,10 +81,10 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error
fg, _ := cache.NewInstance(key)
fg.SetLabels(i.GetLabels().Copy())
fg.SetLabel("volume", match[1])
// Flexgroup don't show any aggregate, node
fg.SetLabel("aggr", "")
// Flexgroup don't show any node
fg.SetLabel("node", "")
fg.SetLabel(style, "flexgroup")
fgAggrMap[key] = set.New()
}

if volumeAggrmetric.GetInstance(key) == nil {
Expand All @@ -98,6 +99,7 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error
v.Logger.Error().Err(err).Str("metric", metricName).Msg("Unable to set value on metric")
}
}
fgAggrMap[key].Add(i.GetLabel("aggr"))
flexgroupAggrsMap[key].Add(i.GetLabel("aggr"))
i.SetLabel(style, "flexgroup_constituent")
i.SetExportable(false)
Expand Down Expand Up @@ -143,6 +145,11 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error
continue
}

// set aggrs label for fg, make sure the order of aggregate is same for each poll
aggrs := fgAggrMap[key].Values()
sort.Strings(aggrs)
fg.SetLabel("aggr", strings.Join(aggrs, ","))

for mkey, m := range data.GetMetrics() {

if !m.IsExportable() && m.GetType() != "float64" {
Expand Down
Loading

0 comments on commit 959b238

Please sign in to comment.