Skip to content

Commit

Permalink
fix: override in templates should be from counters
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss authored and cgrinds committed Oct 10, 2023
1 parent 632a487 commit 0120aee
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 6 deletions.
60 changes: 60 additions & 0 deletions cmd/tools/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,43 @@ func TestExportLabelsExist(t *testing.T) {
}, allTemplatesButEms...)
}

func TestOverrideMetricsExist(t *testing.T) {
// ignore base counters which are not collected in templates but used in collector to cook values
ignore := map[string]bool{
"compound.total": true,
"compound_total": true,
"read_io_type_base": true,
}

visitTemplates(t, func(path string, model TemplateModel) {
// Check if the path contains "zapiperf" or "restperf"
isPerf := strings.Contains(path, "zapiperf") || strings.Contains(path, "restperf")

// If the path is not a performance path, skip the rest of the loop
if !isPerf {
return
}

override := make(map[string]bool)
for key := range model.override {
override[key] = false
}

for _, m := range model.metrics {
if _, exists := model.override[m.left]; exists {
override[m.left] = true
}
}

// Check if each key in the override map exists and is not ignored
for k, v := range override {
if !v && !ignore[k] {
t.Errorf("override option=%s does not exist in counters path=%s", k, shortPath(path))
}
}
}, allTemplatesButEms...)
}

type sorted struct {
got string
want string
Expand Down Expand Up @@ -702,11 +739,33 @@ func unmarshalModel(data []byte) (TemplateModel, error) {
flattenCounters(countersNode, &metrics, make([]string, 0))
addEndpoints(&tm, searchNode(contentNode, "endpoints"), make([]string, 0))
addExportOptions(&tm, searchNode(contentNode, "export_options"))
addOverride(&tm, searchNode(contentNode, "override"))

tm.metrics = metrics
return tm, nil
}

func addOverride(tm *TemplateModel, n *y3.Node) {
if n == nil {
return
}

if tm.override == nil {
tm.override = make(map[string]string)
}

switch n.Tag {
case "!!seq":
for _, child := range n.Content {
if child.Tag == "!!map" && len(child.Content) >= 2 {
key := child.Content[0].Value
val := child.Content[1].Value
tm.override[key] = val
}
}
}
}

func addExportOptions(tm *TemplateModel, n *y3.Node) {
if n == nil {
return
Expand Down Expand Up @@ -799,6 +858,7 @@ type TemplateModel struct {
} `yaml:"export_options"`
metrics []metric
pluginLabels []string
override map[string]string `yaml:"override"`
}

func collectorPath(path string) string {
Expand Down
2 changes: 1 addition & 1 deletion conf/restperf/9.12.0/copy_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ counters:
- system_continuous_engineering_current_copy_count => sce_copy_count_curr

override:
- kb_copied: delta
- KB_copied: delta

export_options:
instance_keys:
Expand Down
2 changes: 1 addition & 1 deletion conf/restperf/9.12.0/nfsv3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ override:
- mknod.total: rate
- null.total: rate
- pathconf.total: rate
- read.symlink_total: rate
- read_symlink.total: rate
- read.total: rate
- readdir.total: rate
- readdirplus.total: rate
Expand Down
2 changes: 1 addition & 1 deletion conf/restperf/9.12.0/nfsv3_node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ override:
- mknod.total: rate
- null.total: rate
- pathconf.total: rate
- read.symlink_total: rate
- read_symlink.total: rate
- read.total: rate
- readdir.total: rate
- readdirplus.total: rate
Expand Down
2 changes: 1 addition & 1 deletion conf/restperf/9.12.0/nfsv4_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export_options:
override:
- access.total: rate
- backchannel_ctl.total: rate
- bind_connections_to_session.total: rate
- bind_conn_to_session.total: rate
- close.total: rate
- commit.total: rate
- compound.total: rate
Expand Down
2 changes: 1 addition & 1 deletion conf/restperf/9.12.0/nfsv4_2_node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ counters:
override:
- access.total: rate
- backchannel_ctl.total: rate
- bind_connections_to_session.total: rate
- bind_conn_to_session.total: rate
- close.total: rate
- commit.total: rate
- compound.total: rate
Expand Down
2 changes: 1 addition & 1 deletion conf/restperf/9.12.0/wafl_comp_aggr_vol_bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export_options:
- volume

override:
- cloud_bin_operation: delta
- cloud_bin_op: delta

0 comments on commit 0120aee

Please sign in to comment.