func (m *StandardMetrics) Dec(label string) {
	m.GetStandardCounter(label).Dec()
	m.promCounter.WithLabelValues(label).Add(-1)
}
Dec decrements the counter by 1.
package metrics
import (
	"github.com/devfeel/rockman/metrics/prometheus"
	"github.com/devfeel/rockman/metrics/standard"
	promclient "github.com/prometheus/client_golang/prometheus"
	"strings"
	"sync"
	"time"
)
const (
	LabelNodeStart          = "NodeStart"
	LabelStartTheWorld      = "StartTheWorld"
	LabelStopTheWorld       = "StopTheWorld"
	LabelTaskExec           = "TaskExec"
	LabelLeaderChange       = "LeaderChange"
	LabelLeaderChangeFailed = "LeaderChangeFailed"
	LabelWorkerNodeOffline  = "WorkerNodeOffline"
	LabelRegistryOnline     = "RegistryOnline"
	LabelRegistryOffline    = "RegistryOffline"
)
type (
	Metrics interface {
		GetStandardCounter(label string) Counter
		Inc(label string)
		Dec(label string)
		Add(label string, value int64)
	}
	Counter interface {
		StartTime() time.Time
		Clear()
		Count() int64
		Dec()
		Inc()
		Add(int64)
	}
	StandardMetrics struct {
		counters    *sync.Map
		promCounter *promclient.CounterVec
	}
	Opts struct {
		Namespace string
		Subsystem string
		Name      string
	}
)
var (
	defaultMetrics Metrics
	labelMap       map[string]string
)
func init() {
	defaultMetrics = NewMetrics()
	labelMap = make(map[string]string)
	labelMap[LabelNodeStart] = LabelNodeStart
	labelMap[LabelStartTheWorld] = LabelStartTheWorld
	labelMap[LabelStopTheWorld] = LabelStopTheWorld
	labelMap[LabelTaskExec] = LabelTaskExec
	labelMap[LabelLeaderChange] = LabelLeaderChange
	labelMap[LabelLeaderChangeFailed] = LabelLeaderChangeFailed
	labelMap[LabelWorkerNodeOffline] = LabelWorkerNodeOffline
	labelMap[LabelRegistryOnline] = LabelRegistryOnline
	labelMap[LabelRegistryOffline] = LabelRegistryOffline
}
func Default() Metrics {
	return defaultMetrics
}
func NewCounter() Counter {
	return standard.NewStandardCounter()
}
func GetAllCountInfo() map[string]int64 {
	m := make(map[string]int64)
	for _, label := range labelMap {
		m[label] = Default().GetStandardCounter(label).Count()
	}
	return m
}
func NewMetrics() Metrics {
	metrics := new(StandardMetrics)
	metrics.counters = new(sync.Map)
	metrics.promCounter = prometheus.InitCounter()
	return metrics
}
func (m *StandardMetrics) GetStandardCounter(label string) Counter {
	var counter Counter
	loadCounter, exists := m.counters.Load(label)
	if !exists {
		counter = NewCounter()
		m.counters.Store(label, counter)
	} else {
		counter = loadCounter.(Counter)
	}
	return counter
}
func (m *StandardMetrics) Inc(label string) {
	m.GetStandardCounter(label).Inc()
	m.promCounter.WithLabelValues(label).Inc()
}