fallback when arg is empty

This commit is contained in:
Owen Williams 2024-01-10 11:24:05 -05:00
parent 362f0e7d11
commit f4693e2217
2 changed files with 10 additions and 6 deletions

View file

@ -450,7 +450,7 @@ func main() {
a.Flag("scrape.discovery-reload-interval", "Interval used by scrape manager to throttle target groups updates.").
Hidden().Default("5s").SetValue(&cfg.scrape.DiscoveryReloadInterval)
a.Flag("scrape.name-escaping-scheme", "method to escape legacy invalid names when sending to an old version of prometheus. can be one of values (default), underscores, or dots").Default(model.DefaultNameEscapingScheme.String()).StringVar(&cfg.scrape.NameEscapingScheme)
a.Flag("scrape.name-escaping-scheme", "method to escape legacy invalid names when sending to an old version of prometheus. can be one of values (default), underscores, or dots").Default(scrape.DefaultNameEscapingScheme.String()).StringVar(&cfg.scrape.NameEscapingScheme)
a.Flag("enable-feature", "Comma separated feature names to enable. Valid options: agent, exemplar-storage, expand-external-labels, memory-snapshot-on-shutdown, promql-at-modifier, promql-negative-offset, promql-per-step-stats, promql-experimental-functions, remote-write-receiver (DEPRECATED), extra-scrape-metrics, new-service-discovery-manager, auto-gomaxprocs, no-default-scrape-port, native-histograms, otlp-write-receiver, utf8-names. See https://prometheus.io/docs/prometheus/latest/feature_flags/ for more details.").
Default("").StringsVar(&cfg.featureList)

View file

@ -168,12 +168,16 @@ func (m *Manager) reload() {
m.mtxScrape.Lock()
defer m.mtxScrape.Unlock()
var err error
model.DefaultNameEscapingScheme, err = model.ToEscapingScheme(m.opts.NameEscapingScheme)
level.Info(m.logger).Log("msg", "ESCAPING SCHEME UPDATED", "scheme", m.opts.NameEscapingScheme)
if err != nil {
level.Error(m.logger).Log("msg", "error setting escaping scheme", "err", err)
return
if m.opts.NameEscapingScheme != "" {
model.NameEscapingScheme, err = model.ToEscapingScheme(m.opts.NameEscapingScheme)
if err != nil {
level.Error(m.logger).Log("msg", "error setting escaping scheme", "err", err)
return
}
} else {
model.NameEscapingScheme = DefaultNameEscapingScheme
}
level.Info(m.logger).Log("msg", "ESCAPING SCHEME", "scheme", model.NameEscapingScheme.String(), "arg", m.opts.NameEscapingScheme)
var wg sync.WaitGroup
for setName, groups := range m.targetSets {