Skip to content

Commit

Permalink
Removed deprecated --metric-count flag (prometheus-community#119)
Browse files Browse the repository at this point in the history
Fixes prometheus-community#82

Signed-off-by: bwplotka <[email protected]>
  • Loading branch information
bwplotka authored and Prateek committed Jan 15, 2025
1 parent 3072d0d commit 8ef94c2
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions metrics/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ type Collector struct {
// NewCollector returns Prometheus collector that can be registered in registry
// that handles metric creation and changes, based on the given configuration.
func NewCollector(cfg Config) *Collector {
if cfg.GaugeMetricCount == 0 {
cfg.GaugeMetricCount = cfg.MetricCount // Handle deprecated field.
}

c := &Collector{
cfg: cfg,
valGen: rand.New(rand.NewSource(time.Now().UnixNano())),
Expand Down Expand Up @@ -80,7 +76,7 @@ func (c *Collector) UpdateNotifyCh() chan struct{} {
}

type Config struct {
MetricCount, GaugeMetricCount, CounterMetricCount, HistogramMetricCount, NativeHistogramMetricCount, SummaryMetricCount int
GaugeMetricCount, CounterMetricCount, HistogramMetricCount, NativeHistogramMetricCount, SummaryMetricCount int

HistogramBuckets, SummaryObjectives int

Expand All @@ -97,8 +93,6 @@ type Config struct {

func NewConfigFromFlags(flagReg func(name, help string) *kingpin.FlagClause) *Config {
cfg := &Config{}
flagReg("metric-count", "Number of gauge metrics to serve. DEPRECATED use --gauge-metric-count instead").Default("0").
IntVar(&cfg.MetricCount)
// NOTE: By default avalanche creates 500 gauges, to keep old behaviour. We could break compatibility,
// but it's less surprising to ask users to adjust and add more types themselves.
flagReg("gauge-metric-count", "Number of gauge metrics to serve.").Default("500").
Expand Down Expand Up @@ -165,9 +159,6 @@ func (c Config) Validate() error {
if c.MinSeriesCount < 0 {
return fmt.Errorf("--min-series-count must be 0 or higher, got %d", c.MinSeriesCount)
}
if c.MetricCount > 0 && c.GaugeMetricCount > 0 {
return fmt.Errorf("--metric-count (set to %v) is deprecated and it means the same as --gauge-metric-count (set to %v); both can't be used in the same time", c.MetricCount, c.GaugeMetricCount)
}
for _, cLabel := range c.ConstLabels {
split := strings.Split(cLabel, "=")
if len(split) != 2 {
Expand Down

0 comments on commit 8ef94c2

Please sign in to comment.