Repository: prometheus/alertmanager
File: featurecontrol/featurecontrol.go (Go)

Code before:
		configs.enableAutoGOMAXPROCS = true
	}
}

func NewFlags(logger log.Logger, features string) (Flagger, error) {
	fc := &Flags{logger: logger}
	opts := []flagOption{}

	if len(features) == 0 {
		return NoopFlags{}, nil
	}

	for _, feature := range strings.Split(features, ",") {
		switch feature {
		case FeatureReceiverNameInMetrics:
			opts = append(opts, enableReceiverNameInMetrics())
			level.Warn(logger).Log("msg", "Experimental receiver name in metrics enabled")
		case FeatureClassicMode:
			opts = append(opts, enableClassicMode())
			level.Warn(logger).Log("msg", "Classic mode enabled")
		case FeatureUTF8StrictMode:
			opts = append(opts, enableUTF8StrictMode())
			level.Warn(logger).Log("msg", "UTF-8 strict mode enabled")
		case FeatureAutoGOMEMLIMIT:
			opts = append(opts, enableAutoGOMEMLIMIT())
			level.Warn(logger).Log("msg", "Automatically set to match the Linux container memory limit. If there is no container limit, or the process is running outside of containers, the system memory total is used.")
		case FeatureAutoGOMAXPROCS:
			opts = append(opts, enableAutoGOMAXPROCS())
			level.Warn(logger).Log("msg", "Automatically set GOMAXPROCS to match Linux container CPU quota")
		default:
			return nil, fmt.Errorf("Unknown option '%s' for --enable-feature", feature)
		}
	}

	for _, opt := range opts {
		opt(fc)
	}

	if fc.classicMode && fc.utf8StrictMode {
		return nil, errors.New("cannot have both classic and UTF-8 modes enabled")
	}

	return fc, nil
}

type NoopFlags struct{}

func (n NoopFlags) EnableReceiverNamesInMetrics() bool { return false }

func (n NoopFlags) ClassicMode() bool { return false }


Review comment (suggestion):
```suggestion
			level.Warn(logger).Log("msg", "Automatically set GOMEMLIMIT to match the Linux container or system memory limit.")
```

Code after:
		configs.enableAutoGOMAXPROCS = true
	}
}

func NewFlags(logger log.Logger, features string) (Flagger, error) {
	fc := &Flags{logger: logger}
	opts := []flagOption{}

	if len(features) == 0 {
		return NoopFlags{}, nil
	}

	for _, feature := range strings.Split(features, ",") {
		switch feature {
		case FeatureReceiverNameInMetrics:
			opts = append(opts, enableReceiverNameInMetrics())
			level.Warn(logger).Log("msg", "Experimental receiver name in metrics enabled")
		case FeatureClassicMode:
			opts = append(opts, enableClassicMode())
			level.Warn(logger).Log("msg", "Classic mode enabled")
		case FeatureUTF8StrictMode:
			opts = append(opts, enableUTF8StrictMode())
			level.Warn(logger).Log("msg", "UTF-8 strict mode enabled")
		case FeatureAutoGOMEMLIMIT:
			opts = append(opts, enableAutoGOMEMLIMIT())
			level.Warn(logger).Log("msg", "Automatically set GOMEMLIMIT to match the Linux container or system memory limit.")
		case FeatureAutoGOMAXPROCS:
			opts = append(opts, enableAutoGOMAXPROCS())
			level.Warn(logger).Log("msg", "Automatically set GOMAXPROCS to match Linux container CPU quota")
		default:
			return nil, fmt.Errorf("Unknown option '%s' for --enable-feature", feature)
		}
	}

	for _, opt := range opts {
		opt(fc)
	}

	if fc.classicMode && fc.utf8StrictMode {
		return nil, errors.New("cannot have both classic and UTF-8 modes enabled")
	}

	return fc, nil
}

type NoopFlags struct{}

func (n NoopFlags) EnableReceiverNamesInMetrics() bool { return false }

func (n NoopFlags) ClassicMode() bool { return false }