Skip to content

Commit a93f747

Browse files
committed
draft add info identifiers in the comments
1 parent 307f915 commit a93f747

11 files changed

+440
-238
lines changed

model/textparse/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ In the rare case that you need to update the textparse lexers, edit promlex.l or
33
`golex -o=promlex.l.go promlex.l`
44

55
Note that you need golex installed:
6-
`go get -u modernc.org/golex`
6+
`go install -u modernc.org/golex@latest`

model/textparse/interface.go

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ 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
56+
5457
// Comment returns the text of the current comment.
5558
// Must only be called after Next returned a comment entry.
5659
// The returned byte slice becomes invalid after the next call to Next.
@@ -110,4 +113,5 @@ const (
110113
EntryComment Entry = 3
111114
EntryUnit Entry = 4
112115
EntryHistogram Entry = 5 // A series with a native histogram as a value.
116+
EntryIdent Entry = 6
113117
)

model/textparse/openmetricslex.l

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ M [a-zA-Z_:]
3636
C [^\n]
3737
S [ ]
3838

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

4141
%yyc c
4242
%yyn c = l.next()
@@ -50,9 +50,13 @@ 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
5354
<sMeta1>\"(\\.|[^\\"])*\" l.state = sMeta2; return tMName
5455
<sMeta1>{M}({M}|{D})* l.state = sMeta2; return tMName
5556
<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
5660
5761
{M}({M}|{D})* l.state = sValue; return tMName
5862
<sValue>\{ l.state = sLabels; return tBraceOpen

0 commit comments

Comments
 (0)