Skip to content

Commit b8fa11b

Browse files
committed
correctly decode ()
1 parent a93f747 commit b8fa11b

10 files changed

+333
-390
lines changed

model/textparse/interface.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ type Parser interface {
5151
// The returned byte slices become invalid after the next call to Next.
5252
Unit() ([]byte, []byte)
5353

54-
// Identifiers returns the identifiers for info metrics
55-
Identifiers() []string
54+
// IdentifyingLabels returns the identifying labels for info metrics
55+
IdentifyingLabels() []string
5656

5757
// Comment returns the text of the current comment.
5858
// Must only be called after Next returned a comment entry.
@@ -113,5 +113,4 @@ const (
113113
EntryComment Entry = 3
114114
EntryUnit Entry = 4
115115
EntryHistogram Entry = 5 // A series with a native histogram as a value.
116-
EntryIdent Entry = 6
117116
)

model/textparse/openmetricslex.l

+8-7
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ func (l *openMetricsLexer) Lex() token {
3333
D [0-9]
3434
L [a-zA-Z_]
3535
M [a-zA-Z_:]
36-
C [^\n]
36+
C [^\n()]
3737
S [ ]
3838

39-
%x sComment sMeta1 sMeta2 sLabels sLValue sValue sTimestamp sExemplar sEValue sETimestamp sMeta3
39+
%x sComment sMeta1 sMeta2 sLabels sLValue sValue sTimestamp sExemplar sEValue sETimestamp sIdens
4040

4141
%yyc c
4242
%yyn c = l.next()
@@ -50,13 +50,14 @@ S [ ]
5050
<sComment>TYPE{S} l.state = sMeta1; return tType
5151
<sComment>UNIT{S} l.state = sMeta1; return tUnit
5252
<sComment>"EOF"\n? l.state = sInit; return tEOFWord
53-
<sComment>ID{S} l.state = sMeta3; return tIdens
5453
<sMeta1>\"(\\.|[^\\"])*\" l.state = sMeta2; return tMName
5554
<sMeta1>{M}({M}|{D})* l.state = sMeta2; return tMName
56-
<sMeta2>{S}{C}*\n l.state = sInit; return tText
57-
<sMeta3>{L}* return tLName
58-
<sMeta3>, return tComma
59-
<sMeta3>\n l.state = sInit; return tLinebreak
55+
<sMeta2>{S}{C}* l.state = sMeta2; return tText
56+
<sMeta2>\( l.state = sIdens; return tParentOpen
57+
<sIdens>{L}({L}|{D})* return tLName
58+
<sIdens>, return tComma
59+
<sIdens>\) l.state = sMeta2; return tParentClose
60+
<sMeta2>\n l.state = sInit; return tLinebreak
6061
6162
{M}({M}|{D})* l.state = sValue; return tMName
6263
<sValue>\{ l.state = sLabels; return tBraceOpen

0 commit comments

Comments
 (0)