Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: csv output for non indexable metrics #2829

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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