package metrics

import (
	"github.com/prometheus/client_golang/prometheus"
	"sigs.k8s.io/controller-runtime/pkg/metrics"
)

const zrEvicterComponent = "zr_evicter"

var (
	ZRUnEvictablePVCCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Subsystem: zrEvicterComponent,
			Name:      "unevictable_pvc_total",
			Help:      "Counter of unevictable pvc",
		},
		[]string{"component", "podname", "pvcname", "namespace"},
	)
	ZREvictPodPVCCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Subsystem: zrEvicterComponent,
			Name:      "evict_pod_pvc_total",
			Help:      "Counter of evict pod pvc",
		},
		[]string{"podname", "pvcname", "namespace"},
	)
	ZREvictPodCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Subsystem: zrEvicterComponent,
			Name:      "evict_pod_total",
			Help:      "Counter of evict pod",
		},
		[]string{"namespace", "nodename", "component", "method"},
	)
	ZREvictPodRetryCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Subsystem: zrEvicterComponent,
			Name:      "evict_pod_retry_total",
			Help:      "Counter of evict pod retry total",
		},
		[]string{"namespace", "nodename", "component"},
	)
	ZREvictPodWaitCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Subsystem: zrEvicterComponent,
			Name:      "evict_pod_wait_total",
			Help:      "Counter of evict pod wait total",
		},
		[]string{"namespace", "nodename", "component"},
	)
	ZRNodeEvicterTaintUpdateCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Subsystem: zrEvicterComponent,
			Name:      "node_evicter_taint_update_total",
			Help:      "Counter of node evicter taint update total",
		},
		[]string{"nodename", "method"},
	)
)

func init() {
	// Register custom metrics with the global prometheus registry
	metrics.Registry.MustRegister(ZRUnEvictablePVCCounter)
	metrics.Registry.MustRegister(ZREvictPodPVCCounter)
	metrics.Registry.MustRegister(ZREvictPodCounter)
	metrics.Registry.MustRegister(ZREvictPodRetryCounter)
	metrics.Registry.MustRegister(ZREvictPodWaitCounter)
	metrics.Registry.MustRegister(ZRNodeEvicterTaintUpdateCounter)
}
