pkg/textparse: handle trailing labels comma (#2752)

This commit is contained in:
Fabian Reinartz 2017-05-22 11:15:40 +02:00 committed by GitHub
parent 10cccd2e45
commit ea09299ca5
3 changed files with 10 additions and 5 deletions

View File

@ -73,7 +73,7 @@ M [a-zA-Z_:]
l.offsets = append(l.offsets, l.i)
<lstateLabels>[ \t]+
<lstateLabels>\} s = lstateValue
<lstateLabels>,?\} s = lstateValue
l.mend = l.i
<lstateLabels>,? s = lstateLName
l.offsets = append(l.offsets, l.i)

View File

@ -264,7 +264,12 @@ yystate20:
yystate21:
c = l.next()
goto yyrule8
switch {
default:
goto yyrule8
case c == '}':
goto yystate22
}
yystate22:
c = l.next()
@ -391,7 +396,7 @@ yyrule5: // {S}({M}|{D})*
yyrule6: // [ \t]+
goto yystate0
yyrule7: // \}
yyrule7: // ,?\}
{
s = lstateValue
l.mend = l.i

View File

@ -31,7 +31,7 @@ func TestParse(t *testing.T) {
input := `# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 4.9351e-05
go_gc_duration_seconds{quantile="0.25"} 7.424100000000001e-05
go_gc_duration_seconds{quantile="0.25",} 7.424100000000001e-05
go_gc_duration_seconds{quantile="0.5",a="b"} 8.3835e-05
go_gc_duration_seconds_count 99
some:aggregate:rate5m{a_b="c"} 1
@ -52,7 +52,7 @@ go_goroutines 33 123123`
v: 4.9351e-05,
lset: labels.FromStrings("__name__", "go_gc_duration_seconds", "quantile", "0"),
}, {
m: `go_gc_duration_seconds{quantile="0.25"}`,
m: `go_gc_duration_seconds{quantile="0.25",}`,
v: 7.424100000000001e-05,
lset: labels.FromStrings("__name__", "go_gc_duration_seconds", "quantile", "0.25"),
}, {