diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index b584187914..5bea62e755 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -617,6 +617,7 @@ func main() { if cfgFile.StorageConfig.TSDBConfig != nil { cfg.tsdb.OutOfOrderTimeWindow = cfgFile.StorageConfig.TSDBConfig.OutOfOrderTimeWindow } + updateGoGC(cfgFile, logger) // Now that the validity of the config is established, set the config // success metrics accordingly, although the config isn't really loaded @@ -1472,6 +1473,14 @@ func reloadConfig(filename string, enableExemplarStorage bool, logger *slog.Logg return fmt.Errorf("one or more errors occurred while applying the new configuration (--config.file=%q)", filename) } + updateGoGC(conf, logger) + + noStepSuqueryInterval.Set(conf.GlobalConfig.EvaluationInterval) + timingsLogger.Info("Completed loading of configuration file", "filename", filename, "totalDuration", time.Since(start)) + return nil +} + +func updateGoGC(conf *config.Config, logger *slog.Logger) { oldGoGC := debug.SetGCPercent(conf.Runtime.GoGC) if oldGoGC != conf.Runtime.GoGC { logger.Info("updated GOGC", "old", oldGoGC, "new", conf.Runtime.GoGC) @@ -1482,10 +1491,6 @@ func reloadConfig(filename string, enableExemplarStorage bool, logger *slog.Logg } else { os.Setenv("GOGC", "off") } - - noStepSuqueryInterval.Set(conf.GlobalConfig.EvaluationInterval) - timingsLogger.Info("Completed loading of configuration file", "filename", filename, "totalDuration", time.Since(start)) - return nil } func startsOrEndsWithQuote(s string) bool {