From b4dd9d9c46b6cb3125cbecdafac2c0ce1acb3f3e Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Fri, 5 Jan 2024 14:47:19 -0500 Subject: [PATCH] require both a feature flag and a globalconfig flag --- cmd/prometheus/main.go | 3 +-- config/config.go | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 4f35e12ac..3657c8e0f 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -216,9 +216,8 @@ func (c *flagConfig) setFeatureListOptions(logger log.Logger) error { config.DefaultGlobalConfig.ScrapeProtocols = config.DefaultProtoFirstScrapeProtocols level.Info(logger).Log("msg", "Experimental created timestamp zero ingestion enabled. Changed default scrape_protocols to prefer PrometheusProto format.", "global.scrape_protocols", fmt.Sprintf("%v", config.DefaultGlobalConfig.ScrapeProtocols)) case "utf8-names": - config.DefaultConfig.GlobalConfig.AllowUTF8Names = true - config.DefaultGlobalConfig.AllowUTF8Names = true model.NameValidationScheme = model.UTF8Validation + level.Info(logger).Log("msg", "Experimental utf8 support enabled") case "": continue case "promql-at-modifier", "promql-negative-offset": diff --git a/config/config.go b/config/config.go index aeb057644..c72d128c5 100644 --- a/config/config.go +++ b/config/config.go @@ -728,6 +728,9 @@ func (c *ScrapeConfig) Validate(globalConfig GlobalConfig) error { } if globalConfig.AllowUTF8Names { + if model.NameValidationScheme != model.UTF8Validation { + return fmt.Errorf("utf8 name support requested but feature not enabled via --enable-feature=utf8-names") + } c.AllowUTF8Names = true }