-
Notifications
You must be signed in to change notification settings - Fork 781
/
deprecated.go
38 lines (30 loc) · 950 Bytes
/
deprecated.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package flagext
import (
"flag"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
util_log "github.com/cortexproject/cortex/pkg/util/log"
)
// DeprecatedFlagsUsed is the metric that counts deprecated flags set.
var DeprecatedFlagsUsed = promauto.NewCounter(
prometheus.CounterOpts{
Namespace: "cortex",
Name: "deprecated_flags_inuse_total",
Help: "The number of deprecated flags currently set.",
})
type deprecatedFlag struct {
name string
}
func (deprecatedFlag) String() string {
return "deprecated"
}
func (d deprecatedFlag) Set(string) error {
level.Warn(util_log.Logger).Log("msg", "flag disabled", "flag", d.name)
DeprecatedFlagsUsed.Inc()
return nil
}
// DeprecatedFlag logs a warning when you try to use it.
func DeprecatedFlag(f *flag.FlagSet, name, message string) {
f.Var(deprecatedFlag{name}, name, message)
}