mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
refac: remove NewOpenMetricsParserWithOpts
Signed-off-by: Manik Rana <manikrana54@gmail.com>
This commit is contained in:
parent
e4a9124db0
commit
50c2d2ce69
|
@ -117,17 +117,8 @@ func WithOMParserCTSeriesSkipped() OpenMetricsOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOpenMetricsParser returns a new parser of the byte slice.
|
// NewOpenMetricsParser returns a new parser of the byte slice with option to skip CT series parsing.
|
||||||
func NewOpenMetricsParser(b []byte, st *labels.SymbolTable) Parser {
|
func NewOpenMetricsParser(b []byte, st *labels.SymbolTable, opts ...OpenMetricsOption) Parser {
|
||||||
return &OpenMetricsParser{
|
|
||||||
l: &openMetricsLexer{b: b},
|
|
||||||
builder: labels.NewScratchBuilderWithSymbolTable(st, 16),
|
|
||||||
skipCTSeries: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewOpenMetricsParserWithOpts returns a new parser of the byte slice with options.
|
|
||||||
func NewOpenMetricsParserWithOpts(b []byte, st *labels.SymbolTable, opts ...OpenMetricsOption) Parser {
|
|
||||||
options := &openMetricsParserOptions{}
|
options := &openMetricsParserOptions{}
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
|
@ -143,6 +134,7 @@ func NewOpenMetricsParserWithOpts(b []byte, st *labels.SymbolTable, opts ...Open
|
||||||
return parser
|
return parser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Series returns the bytes of the series, the timestamp if set, and the value
|
// Series returns the bytes of the series, the timestamp if set, and the value
|
||||||
// of the current sample.
|
// of the current sample.
|
||||||
func (p *OpenMetricsParser) Series() ([]byte, *int64, float64) {
|
func (p *OpenMetricsParser) Series() ([]byte, *int64, float64) {
|
||||||
|
|
|
@ -330,7 +330,7 @@ fizz_created 17.0`
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p := NewOpenMetricsParserWithOpts([]byte(input), labels.NewSymbolTable(), WithOMParserCTSeriesSkipped())
|
p := NewOpenMetricsParser([]byte(input), labels.NewSymbolTable(), WithOMParserCTSeriesSkipped())
|
||||||
checkParseResults(t, p, exp)
|
checkParseResults(t, p, exp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -918,7 +918,7 @@ foobar{quantile="0.99"} 150.0`
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p := NewOpenMetricsParserWithOpts([]byte(input), labels.NewSymbolTable(), WithOMParserCTSeriesSkipped())
|
p := NewOpenMetricsParser([]byte(input), labels.NewSymbolTable(), WithOMParserCTSeriesSkipped())
|
||||||
i := 0
|
i := 0
|
||||||
|
|
||||||
var res labels.Labels
|
var res labels.Labels
|
||||||
|
@ -955,7 +955,7 @@ go_gc_duration_seconds
|
||||||
go_gc_duration_seconds_created`)
|
go_gc_duration_seconds_created`)
|
||||||
|
|
||||||
st := labels.NewSymbolTable()
|
st := labels.NewSymbolTable()
|
||||||
parser := NewOpenMetricsParserWithOpts(input, st, WithOMParserCTSeriesSkipped()).(*OpenMetricsParser)
|
parser := NewOpenMetricsParser(input, st, WithOMParserCTSeriesSkipped()).(*OpenMetricsParser)
|
||||||
|
|
||||||
// Modify the original parser state
|
// Modify the original parser state
|
||||||
_, err := parser.Next()
|
_, err := parser.Next()
|
||||||
|
|
|
@ -479,10 +479,15 @@ const (
|
||||||
promtestdataSampleCount = 410
|
promtestdataSampleCount = 410
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func newOpenMetricsParserNoOptions(b []byte, st *labels.SymbolTable) Parser {
|
||||||
|
return NewOpenMetricsParser(b, st)
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkParse(b *testing.B) {
|
func BenchmarkParse(b *testing.B) {
|
||||||
for parserName, parser := range map[string]func([]byte, *labels.SymbolTable) Parser{
|
for parserName, parser := range map[string]func([]byte, *labels.SymbolTable) Parser{
|
||||||
"prometheus": NewPromParser,
|
"prometheus": NewPromParser,
|
||||||
"openmetrics": NewOpenMetricsParser,
|
"openmetrics": newOpenMetricsParserNoOptions,
|
||||||
} {
|
} {
|
||||||
for _, fn := range []string{"promtestdata.txt", "promtestdata.nometa.txt"} {
|
for _, fn := range []string{"promtestdata.txt", "promtestdata.nometa.txt"} {
|
||||||
f, err := os.Open(fn)
|
f, err := os.Open(fn)
|
||||||
|
|
Loading…
Reference in a new issue