package allowlist

import "github.com/prometheus/client_golang/prometheus"

const (
	namespace = "tidb_management_service"
	subsystem = "allowlist"
)

var (
	// lock list
	OrgLockListGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "org_lock_list",
			Help:      "How many org locks exist on a service, partitioned by org_id.",
		}, []string{"org_id"})
	OrgLockedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "org_locked_total",
			Help:      "How many org locked on a service, partitioned by org_id.",
		}, []string{"org_id"})
	AllowListReloadRemoteFailedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "allow_list_reload_failed_total",
			Help:      "How many allowlist reload failed on a service.",
		}, []string{})
	AllowListWatchRemoteFailedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "allow_list_watch_failed_total",
			Help:      "How many allowlist watch failed on a service.",
		}, []string{})
	AllowListGetOrgInfoCacheHitCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "allow_list_get_org_info_cache_hit_total",
			Help:      "getOrgInfo(org): cache hit count.",
		}, []string{})
	AllowListGetOrgInfoCacheMissCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subsystem,
			Name:      "allow_list_get_org_info_cache_miss_total",
			Help:      "getOrgInfo(org): cache miss count.",
		}, []string{})
)

func init() {
	prometheus.MustRegister(
		OrgLockListGauge,
		OrgLockedCounter,
		AllowListReloadRemoteFailedCounter,
		AllowListWatchRemoteFailedCounter,
		AllowListGetOrgInfoCacheHitCounter,
		AllowListGetOrgInfoCacheMissCounter,
	)
}
