Repository: prometheus/prometheus
File: config/config.go (Go)

Code before:
	*c = *gc
	return nil
}

// isZero returns true iff the global config is the zero value.
func (c *GlobalConfig) isZero() bool {
	return c.ExternalLabels.IsEmpty() &&
		c.ScrapeInterval == 0 &&
		c.ScrapeTimeout == 0 &&
		c.EvaluationInterval == 0 &&
		c.RuleQueryOffset == 0 &&
		c.QueryLogFile == "" &&
		c.ScrapeFailureLogFile == "" &&
		c.ScrapeProtocols == nil &&
		!c.ConvertClassicHistogramsToNHCB &&
		!c.AlwaysScrapeClassicHistograms
}

// RuntimeConfig configures the values for the process behavior.
type RuntimeConfig struct {
	// The Go garbage collection target percentage.
	GoGC int `yaml:"gogc,omitempty"`

	// Below are guidelines for adding a new field:
	//
	// Confirm that adding it here, rather than via a flag, is the best approach.
	//
	// Consider when the new field is first applied: at the very beginning of instance
	// startup, after the TSDB is loaded etc. See https://github.com/prometheus/prometheus/pull/16491
	// for an example.
	//
	// Provide a test covering various scenarios: empty config file, empty or incomplete runtime
	// config block, precedence over other inputs (e.g., env vars, if applicable) etc.
	// See TestRuntimeGOGCConfig (or https://github.com/prometheus/prometheus/pull/15238).
	// The test should also verify behavior on reloads, since this config should be
	// adjustable at "runtime".
}

// isZero returns true iff the global config is the zero value.
func (c *RuntimeConfig) isZero() bool {
	return c.GoGC == 0
}

type ScrapeConfigs struct {
	ScrapeConfigs []*ScrapeConfig `yaml:"scrape_configs,omitempty"`
}

// ScrapeConfig configures a scraping unit for Prometheus.
type ScrapeConfig struct {
	// The job name to which the job label is set by default.
	JobName string `yaml:"job_name"`

Review comment (suggestion):
This is misleading.

There is no "best approach". The defining design pattern we use for "flag vs config" is if we want the configuration item to be static (at startup only) or dynamic (in configuration).

Any flag that we want to be dynamic needs to have a configuration file entry. So the question if "flag vs config" is up to the user needs.

Code after:
	*c = *gc
	return nil
}

// isZero returns true iff the global config is the zero value.
func (c *GlobalConfig) isZero() bool {
	return c.ExternalLabels.IsEmpty() &&
		c.ScrapeInterval == 0 &&
		c.ScrapeTimeout == 0 &&
		c.EvaluationInterval == 0 &&
		c.RuleQueryOffset == 0 &&
		c.QueryLogFile == "" &&
		c.ScrapeFailureLogFile == "" &&
		c.ScrapeProtocols == nil &&
		!c.ConvertClassicHistogramsToNHCB &&
		!c.AlwaysScrapeClassicHistograms
}

// RuntimeConfig configures the values for the process behavior.
type RuntimeConfig struct {
	// The Go garbage collection target percentage.
	GoGC int `yaml:"gogc,omitempty"`

	// Below are guidelines for adding a new field:
	//
	// For config that shouldn't change after startup, you might want to use
	// flags https://prometheus.io/docs/prometheus/latest/command-line/prometheus/.
	//
	// Consider when the new field is first applied: at the very beginning of instance
	// startup, after the TSDB is loaded etc. See https://github.com/prometheus/prometheus/pull/16491
	// for an example.
	//
	// Provide a test covering various scenarios: empty config file, empty or incomplete runtime
	// config block, precedence over other inputs (e.g., env vars, if applicable) etc.
	// See TestRuntimeGOGCConfig (or https://github.com/prometheus/prometheus/pull/15238).
	// The test should also verify behavior on reloads, since this config should be
	// adjustable at runtime.
}

// isZero returns true iff the global config is the zero value.
func (c *RuntimeConfig) isZero() bool {
	return c.GoGC == 0
}

type ScrapeConfigs struct {
	ScrapeConfigs []*ScrapeConfig `yaml:"scrape_configs,omitempty"`
}

// ScrapeConfig configures a scraping unit for Prometheus.
type ScrapeConfig struct {
	// The job name to which the job label is set by default.