Repository: etcd-io/etcd
File: server/etcdserver/metrics.go (Go)

Code before:
			Name:      "version",
			Help:      "Which version is running. 1 for 'server_version' label with current version.",
		},
		[]string{"server_version"},
	)
	currentGoVersion = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "etcd",
			Subsystem: "server",
			Name:      "go_version",
			Help:      "Which Go version server is running with. 1 for 'server_go_version' label with current version.",
		},
		[]string{"server_go_version"},
	)
	serverID = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "etcd",
			Subsystem: "server",
			Name:      "id",
			Help:      "Server or member ID in hexadecimal format. 1 for 'server_id' label with current ID.",
		},
		[]string{"server_id"},
	)
	etcdServerFeatureEnabled = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "etcd",
			Subsystem: "server",
			Name:      "etcd_server_feature_enabled",
			Help:      "Whether or not a feature is enabled. 1 is enabled, 0 is not.",
		},
		[]string{"name", "stage"},
	)
	fdUsed = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "os",
		Subsystem: "fd",
		Name:      "used",
		Help:      "The number of used file descriptors.",
	})
	fdLimit = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "os",
		Subsystem: "fd",
		Name:      "limit",
		Help:      "The file descriptor limit.",
	})
)

func init() {
	prometheus.MustRegister(hasLeader)
	prometheus.MustRegister(isLeader)
	prometheus.MustRegister(leaderChanges)
	prometheus.MustRegister(heartbeatSendFailures)

Review comment (suggestion):
Remove `Namespace` and `SubSystem`, they are added as suffix to metric name, which makes the metric harder to discover by name. They are not recommended anymore.

Code after:
			Name:      "version",
			Help:      "Which version is running. 1 for 'server_version' label with current version.",
		},
		[]string{"server_version"},
	)
	currentGoVersion = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "etcd",
			Subsystem: "server",
			Name:      "go_version",
			Help:      "Which Go version server is running with. 1 for 'server_go_version' label with current version.",
		},
		[]string{"server_go_version"},
	)
	serverID = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "etcd",
			Subsystem: "server",
			Name:      "id",
			Help:      "Server or member ID in hexadecimal format. 1 for 'server_id' label with current ID.",
		},
		[]string{"server_id"},
	)
	serverFeatureEnabled = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "etcd_server_feature_enabled",
			Help: "Whether or not a feature is enabled. 1 is enabled, 0 is not.",
		},
		[]string{"name", "stage"},
	)
	fdUsed = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "os",
		Subsystem: "fd",
		Name:      "used",
		Help:      "The number of used file descriptors.",
	})
	fdLimit = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "os",
		Subsystem: "fd",
		Name:      "limit",
		Help:      "The file descriptor limit.",
	})
)

func init() {
	prometheus.MustRegister(hasLeader)
	prometheus.MustRegister(isLeader)
	prometheus.MustRegister(leaderChanges)
	prometheus.MustRegister(heartbeatSendFailures)
	prometheus.MustRegister(applySnapshotInProgress)
	prometheus.MustRegister(proposalsCommitted)