Skip to content

Commit

Permalink
fix: csv output for non indexable metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
leonyork committed Jan 12, 2023
1 parent 074b532 commit 4e1441c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions output/csv/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ func newOutput(params output.Params) (*Output, error) {
ignoredTags := []string{}
tags := params.ScriptOptions.SystemTags.Map()
for tag, flag := range tags {
systemTag, err := metrics.SystemTagString(tag)
if err != nil {
return nil, err
}

// The non-indexable system tags are neither a "resTag"
// nor an "ignoreTag". They aren't a "resTag" as they
// aren't added as a column in the CSV. Yet they also
// shouldn't be ignored as they are added to the
// "metadata" column
if metrics.NonIndexableSystemTags.Has(systemTag) {
continue
}

if flag {
resTags = append(resTags, tag)
} else {
Expand Down
5 changes: 3 additions & 2 deletions output/csv/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func TestRun(t *testing.T) {
"url": "val2",
"error": "val3",
"tag4": "val4",
"vu": "1",
}),
},
Metadata: map[string]string{},
Expand All @@ -257,7 +258,7 @@ func TestRun(t *testing.T) {
timeFormat: "",
outputContent: "metric_name,timestamp,metric_value,check,error,extra_tags,metadata\n" +
"my_metric,1562324643,1.000000,val1,val3,url=val2,\n" +
"my_metric,1562324644,1.000000,val1,val3,tag4=val4&url=val2,\n",
"my_metric,1562324644,1.000000,val1,val3,tag4=val4&url=val2&vu=1,\n",
},
{
samples: []metrics.SampleContainer{
Expand Down Expand Up @@ -350,7 +351,7 @@ func TestRun(t *testing.T) {
Environment: env,
ConfigArgument: data.fileName,
ScriptOptions: lib.Options{
SystemTags: metrics.NewSystemTagSet(metrics.TagError | metrics.TagCheck),
SystemTags: metrics.NewSystemTagSet(metrics.TagError | metrics.TagCheck | metrics.TagVU),
},
})
require.NoError(t, err)
Expand Down

0 comments on commit 4e1441c

Please sign in to comment.