lib/protoparser/prometheus: skip leading whitespace from tag names

This commit is contained in:
Aliaksandr Valialkin 2020-02-16 19:06:02 +02:00
parent e7ba18b0d9
commit 71a52f5f90
2 changed files with 27 additions and 2 deletions

View file

@ -236,7 +236,7 @@ func unmarshalTags(dst []Tag, s string, noEscapes bool) (string, []Tag, error) {
if len(s) == 0 || s[0] != ',' {
return s, dst, fmt.Errorf("missing comma after tag %s=%q", key, value)
}
s = s[1:]
s = skipLeadingWhitespace(s[1:])
}
}

View file

@ -253,7 +253,7 @@ func TestRowsUnmarshalSuccess(t *testing.T) {
})
// Multi lines with invalid line
f("\t foo\t {} 0.3\t 2\naaa\n bar.baz 0.34 43\n", &Rows{
f("\t foo\t { } 0.3\t 2\naaa\n bar.baz 0.34 43\n", &Rows{
Rows: []Row{
{
Metric: "foo",
@ -267,4 +267,29 @@ func TestRowsUnmarshalSuccess(t *testing.T) {
},
},
})
// Spaces around tags
f(`vm_accounting { name="vminsertRows", accountID = "1" , projectID= "1" } 277779100`, &Rows{
Rows: []Row{
{
Metric: "vm_accounting",
Tags: []Tag{
{
Key: "name",
Value: "vminsertRows",
},
{
Key: "accountID",
Value: "1",
},
{
Key: "projectID",
Value: "1",
},
},
Value: 277779100,
Timestamp: 0,
},
},
})
}