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.
|
||||
func NewOpenMetricsParser(b []byte, st *labels.SymbolTable) 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 {
|
||||
// NewOpenMetricsParser returns a new parser of the byte slice with option to skip CT series parsing.
|
||||
func NewOpenMetricsParser(b []byte, st *labels.SymbolTable, opts ...OpenMetricsOption) Parser {
|
||||
options := &openMetricsParserOptions{}
|
||||
|
||||
for _, opt := range opts {
|
||||
|
@ -143,6 +134,7 @@ func NewOpenMetricsParserWithOpts(b []byte, st *labels.SymbolTable, opts ...Open
|
|||
return parser
|
||||
}
|
||||
|
||||
|
||||
// Series returns the bytes of the series, the timestamp if set, and the value
|
||||
// of the current sample.
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
var res labels.Labels
|
||||
|
@ -955,7 +955,7 @@ go_gc_duration_seconds
|
|||
go_gc_duration_seconds_created`)
|
||||
|
||||
st := labels.NewSymbolTable()
|
||||
parser := NewOpenMetricsParserWithOpts(input, st, WithOMParserCTSeriesSkipped()).(*OpenMetricsParser)
|
||||
parser := NewOpenMetricsParser(input, st, WithOMParserCTSeriesSkipped()).(*OpenMetricsParser)
|
||||
|
||||
// Modify the original parser state
|
||||
_, err := parser.Next()
|
||||
|
|
|
@ -479,10 +479,15 @@ const (
|
|||
promtestdataSampleCount = 410
|
||||
)
|
||||
|
||||
|
||||
func newOpenMetricsParserNoOptions(b []byte, st *labels.SymbolTable) Parser {
|
||||
return NewOpenMetricsParser(b, st)
|
||||
}
|
||||
|
||||
func BenchmarkParse(b *testing.B) {
|
||||
for parserName, parser := range map[string]func([]byte, *labels.SymbolTable) Parser{
|
||||
"prometheus": NewPromParser,
|
||||
"openmetrics": NewOpenMetricsParser,
|
||||
"openmetrics": newOpenMetricsParserNoOptions,
|
||||
} {
|
||||
for _, fn := range []string{"promtestdata.txt", "promtestdata.nometa.txt"} {
|
||||
f, err := os.Open(fn)
|
||||
|
|
Loading…
Reference in a new issue