mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-20 00:10:23 -05:00
feat[scrape]: add ST parsing support to scrape AppenderV2 flow
Signed-off-by: bwplotka <bwplotka@gmail.com>
This commit is contained in:
parent
d9fbe7b0ae
commit
12f5f2de3c
5 changed files with 25 additions and 3 deletions
|
|
@ -269,6 +269,7 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error {
|
|||
case "created-timestamp-zero-ingestion":
|
||||
// NOTE(bwplotka): Once AppendableV1 is removed, there will be only the TSDB and agent flags.
|
||||
c.scrape.EnableStartTimestampZeroIngestion = true
|
||||
c.scrape.ParseST = true
|
||||
c.web.STZeroIngestionEnabled = true
|
||||
c.tsdb.EnableSTAsZeroSample = true
|
||||
c.agent.EnableSTAsZeroSample = true
|
||||
|
|
@ -280,6 +281,7 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error {
|
|||
logger.Info("Experimental start timestamp zero ingestion enabled. Changed default scrape_protocols to prefer PrometheusProto format.", "global.scrape_protocols", fmt.Sprintf("%v", config.DefaultGlobalConfig.ScrapeProtocols))
|
||||
case "st-storage":
|
||||
// TODO(bwplotka): Implement ST Storage as per PROM-60 and document this hidden feature flag.
|
||||
c.scrape.ParseST = true
|
||||
c.tsdb.EnableSTStorage = true
|
||||
c.agent.EnableSTStorage = true
|
||||
|
||||
|
|
|
|||
|
|
@ -115,8 +115,19 @@ type Options struct {
|
|||
|
||||
// Option to enable the ingestion of the created timestamp as a synthetic zero sample.
|
||||
// See: https://github.com/prometheus/proposals/blob/main/proposals/2023-06-13_created-timestamp.md
|
||||
//
|
||||
// NOTE: This option has no effect for AppenderV2 and will be removed with the AppenderV1
|
||||
// removal.
|
||||
EnableStartTimestampZeroIngestion bool
|
||||
|
||||
// ParseST controls if ST should be parsed and appended from the scrape format
|
||||
// notably from the expensive OpenMetrics 1.0 _created line flow. This adds some
|
||||
// overhead and can yield wrong ST values on OM1 edge cases.
|
||||
//
|
||||
// This only applies to AppenderV2 flow.
|
||||
// TODO: Move this option to OM1 parser and use only on OM1 flow
|
||||
ParseST bool
|
||||
|
||||
// EnableTypeAndUnitLabels represents type-and-unit-labels feature flag.
|
||||
EnableTypeAndUnitLabels bool
|
||||
|
||||
|
|
|
|||
|
|
@ -767,6 +767,7 @@ func TestManagerSTZeroIngestion(t *testing.T) {
|
|||
app := teststorage.NewAppendable()
|
||||
discoveryManager, scrapeManager := runManagers(t, ctx, &Options{
|
||||
EnableStartTimestampZeroIngestion: testSTZeroIngest,
|
||||
ParseST: testSTZeroIngest,
|
||||
skipOffsetting: true,
|
||||
}, app, nil)
|
||||
defer scrapeManager.Stop()
|
||||
|
|
@ -953,6 +954,7 @@ func TestManagerSTZeroIngestionHistogram(t *testing.T) {
|
|||
app := teststorage.NewAppendable()
|
||||
discoveryManager, scrapeManager := runManagers(t, ctx, &Options{
|
||||
EnableStartTimestampZeroIngestion: tc.enableSTZeroIngestion,
|
||||
ParseST: tc.enableSTZeroIngestion,
|
||||
skipOffsetting: true,
|
||||
}, app, nil)
|
||||
defer scrapeManager.Stop()
|
||||
|
|
@ -1065,6 +1067,7 @@ func TestNHCBAndSTZeroIngestion(t *testing.T) {
|
|||
app := teststorage.NewAppendable()
|
||||
discoveryManager, scrapeManager := runManagers(t, ctx, &Options{
|
||||
EnableStartTimestampZeroIngestion: true,
|
||||
ParseST: true,
|
||||
skipOffsetting: true,
|
||||
}, app, nil)
|
||||
defer scrapeManager.Stop()
|
||||
|
|
|
|||
|
|
@ -870,6 +870,7 @@ type scrapeLoop struct {
|
|||
|
||||
// Options from scrape.Options.
|
||||
enableSTZeroIngestion bool
|
||||
parseST bool // Used by AppenderV2 only.
|
||||
enableTypeAndUnitLabels bool
|
||||
reportExtraMetrics bool
|
||||
appendMetadataToWAL bool
|
||||
|
|
@ -1223,7 +1224,12 @@ func newScrapeLoop(opts scrapeLoopOptions) *scrapeLoop {
|
|||
validationScheme: opts.sp.config.MetricNameValidationScheme,
|
||||
|
||||
// scrape.Options.
|
||||
enableSTZeroIngestion: opts.sp.options.EnableStartTimestampZeroIngestion,
|
||||
enableSTZeroIngestion: opts.sp.options.EnableStartTimestampZeroIngestion,
|
||||
// parseST was added recently. Before EnableStartTimestampZeroIngestion
|
||||
// was enabling parsing ST. For non-Prometheus users of the scrape
|
||||
// manager, we ensure appenderV2 parseST is set on EnableStartTimestampZeroIngestion
|
||||
// This will be removed when EnableStartTimestampZeroIngestion is removed.
|
||||
parseST: opts.sp.options.ParseST || opts.sp.options.EnableStartTimestampZeroIngestion,
|
||||
enableTypeAndUnitLabels: opts.sp.options.EnableTypeAndUnitLabels,
|
||||
appendMetadataToWAL: opts.sp.options.AppendMetadata,
|
||||
passMetadataInContext: opts.sp.options.PassMetadataInContext,
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func (sl *scrapeLoopAppenderV2) append(b []byte, contentType string, ts time.Tim
|
|||
IgnoreNativeHistograms: !sl.enableNativeHistogramScraping,
|
||||
ConvertClassicHistogramsToNHCB: sl.convertClassicHistToNHCB,
|
||||
KeepClassicOnClassicAndNativeHistograms: sl.alwaysScrapeClassicHist,
|
||||
OpenMetricsSkipSTSeries: sl.enableSTZeroIngestion,
|
||||
OpenMetricsSkipSTSeries: sl.parseST,
|
||||
FallbackContentType: sl.fallbackScrapeProtocol,
|
||||
})
|
||||
if p == nil {
|
||||
|
|
@ -254,7 +254,7 @@ loop:
|
|||
}
|
||||
|
||||
st := int64(0)
|
||||
if sl.enableSTZeroIngestion {
|
||||
if sl.parseST {
|
||||
// p.StartTimestamp() tend to be expensive (e.g. OM1). Do it only if we care.
|
||||
st = p.StartTimestamp()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue