mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
refac: allow opt-in to OM CT ingestion
Signed-off-by: Manik Rana <manikrana54@gmail.com>
This commit is contained in:
parent
82064d42b8
commit
d14eb733e8
|
@ -80,7 +80,7 @@ type Parser interface {
|
||||||
//
|
//
|
||||||
// This function always returns a valid parser, but might additionally
|
// This function always returns a valid parser, but might additionally
|
||||||
// return an error if the content type cannot be parsed.
|
// return an error if the content type cannot be parsed.
|
||||||
func New(b []byte, contentType string, parseClassicHistograms bool, st *labels.SymbolTable) (Parser, error) {
|
func New(b []byte, contentType string, parseClassicHistograms bool, skipOMSeries bool, st *labels.SymbolTable) (Parser, error) {
|
||||||
if contentType == "" {
|
if contentType == "" {
|
||||||
return NewPromParser(b, st), nil
|
return NewPromParser(b, st), nil
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,10 @@ func New(b []byte, contentType string, parseClassicHistograms bool, st *labels.S
|
||||||
}
|
}
|
||||||
switch mediaType {
|
switch mediaType {
|
||||||
case "application/openmetrics-text":
|
case "application/openmetrics-text":
|
||||||
return NewOpenMetricsParser(b, st, WithOMParserCTSeriesSkipped()), nil
|
opts := func(o * openMetricsParserOptions) {
|
||||||
|
o.SkipCTSeries = skipOMSeries
|
||||||
|
}
|
||||||
|
return NewOpenMetricsParser(b, st, opts), nil
|
||||||
case "application/vnd.google.protobuf":
|
case "application/vnd.google.protobuf":
|
||||||
return NewProtobufParser(b, parseClassicHistograms, st), nil
|
return NewProtobufParser(b, parseClassicHistograms, st), nil
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1489,7 +1489,7 @@ type appendErrors struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sl *scrapeLoop) append(app storage.Appender, b []byte, contentType string, ts time.Time) (total, added, seriesAdded int, err error) {
|
func (sl *scrapeLoop) append(app storage.Appender, b []byte, contentType string, ts time.Time) (total, added, seriesAdded int, err error) {
|
||||||
p, err := textparse.New(b, contentType, sl.scrapeClassicHistograms, sl.symbolTable)
|
p, err := textparse.New(b, contentType, sl.scrapeClassicHistograms, sl.enableCTZeroIngestion, sl.symbolTable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(sl.l).Log(
|
level.Debug(sl.l).Log(
|
||||||
"msg", "Invalid content type on scrape, using prometheus parser as fallback.",
|
"msg", "Invalid content type on scrape, using prometheus parser as fallback.",
|
||||||
|
|
|
@ -1482,7 +1482,7 @@ func TestScrapeLoopAppendCacheEntryButErrNotFound(t *testing.T) {
|
||||||
fakeRef := storage.SeriesRef(1)
|
fakeRef := storage.SeriesRef(1)
|
||||||
expValue := float64(1)
|
expValue := float64(1)
|
||||||
metric := []byte(`metric{n="1"} 1`)
|
metric := []byte(`metric{n="1"} 1`)
|
||||||
p, warning := textparse.New(metric, "", false, labels.NewSymbolTable())
|
p, warning := textparse.New(metric, "", false, false, labels.NewSymbolTable())
|
||||||
require.NoError(t, warning)
|
require.NoError(t, warning)
|
||||||
|
|
||||||
var lset labels.Labels
|
var lset labels.Labels
|
||||||
|
|
Loading…
Reference in a new issue