mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
scraping: re-use symbol table for scrape loops
One symbol table for all loops in the same scrape pool, i.e. from the same job. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
0403d098e1
commit
abb3a62f04
|
@ -163,6 +163,7 @@ func newScrapePool(cfg *config.ScrapeConfig, app storage.Appendable, offsetSeed
|
|||
func(l labels.Labels) labels.Labels { return mutateReportSampleLabels(l, opts.target) },
|
||||
func(ctx context.Context) storage.Appender { return app.Appender(ctx) },
|
||||
cache,
|
||||
sp.symbolTable,
|
||||
offsetSeed,
|
||||
opts.honorTimestamps,
|
||||
opts.trackTimestampsStaleness,
|
||||
|
@ -809,6 +810,7 @@ type scrapeLoop struct {
|
|||
enableCTZeroIngestion bool
|
||||
|
||||
appender func(ctx context.Context) storage.Appender
|
||||
symbolTable *labels.SymbolTable
|
||||
sampleMutator labelsMutator
|
||||
reportSampleMutator labelsMutator
|
||||
|
||||
|
@ -1088,6 +1090,7 @@ func newScrapeLoop(ctx context.Context,
|
|||
reportSampleMutator labelsMutator,
|
||||
appender func(ctx context.Context) storage.Appender,
|
||||
cache *scrapeCache,
|
||||
symbolTable *labels.SymbolTable,
|
||||
offsetSeed uint64,
|
||||
honorTimestamps bool,
|
||||
trackTimestampsStaleness bool,
|
||||
|
@ -1133,6 +1136,7 @@ func newScrapeLoop(ctx context.Context,
|
|||
buffers: buffers,
|
||||
cache: cache,
|
||||
appender: appender,
|
||||
symbolTable: symbolTable,
|
||||
sampleMutator: sampleMutator,
|
||||
reportSampleMutator: reportSampleMutator,
|
||||
stopped: make(chan struct{}),
|
||||
|
@ -1431,7 +1435,7 @@ type appendErrors struct {
|
|||
}
|
||||
|
||||
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)
|
||||
p, err := textparse.New(b, contentType, sl.scrapeClassicHistograms, sl.symbolTable)
|
||||
if err != nil {
|
||||
level.Debug(sl.l).Log(
|
||||
"msg", "Invalid content type on scrape, using prometheus parser as fallback.",
|
||||
|
|
|
@ -660,6 +660,7 @@ func newBasicScrapeLoop(t testing.TB, ctx context.Context, scraper scraper, app
|
|||
nopMutator,
|
||||
app,
|
||||
nil,
|
||||
nil,
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
|
@ -800,6 +801,7 @@ func TestScrapeLoopRun(t *testing.T) {
|
|||
nopMutator,
|
||||
app,
|
||||
nil,
|
||||
nil,
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
|
@ -942,6 +944,7 @@ func TestScrapeLoopMetadata(t *testing.T) {
|
|||
nopMutator,
|
||||
func(ctx context.Context) storage.Appender { return nopAppender{} },
|
||||
cache,
|
||||
labels.NewSymbolTable(),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
|
@ -1470,7 +1473,7 @@ func TestScrapeLoopAppendCacheEntryButErrNotFound(t *testing.T) {
|
|||
fakeRef := storage.SeriesRef(1)
|
||||
expValue := float64(1)
|
||||
metric := []byte(`metric{n="1"} 1`)
|
||||
p, warning := textparse.New(metric, "", false)
|
||||
p, warning := textparse.New(metric, "", false, labels.NewSymbolTable())
|
||||
require.NoError(t, warning)
|
||||
|
||||
var lset labels.Labels
|
||||
|
|
Loading…
Reference in a new issue