package resourcepool

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

// Metric Labels
const (
	LabelKeyResourcePoolId = "resource_pool_id"
	LabelKeyOwnerId        = "owner_id"
	LabelKeyErrortype      = "error_type"

	CheckIdleErrorTypeListIdle = "list_idle_resource_pool_failed"
)

var (
	CheckIdleWorkerRunsTotal = prometheus.NewCounter(
		prometheus.CounterOpts{
			Name: "resource_pool_worker_check_idle_runs_total",
			Help: "Total number of check idle resource pools worker runs",
		},
	)

	CheckIdleErrorTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "resource_pool_check_idle_error_total",
			Help: "Total number of check idle resource pools failures",
		},
		[]string{LabelKeyErrortype},
	)

	IdleSeconds = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "resource_pool_idle_seconds",
			Help: "The duration (in seconds) that a resource pool has been idle",
		},
		[]string{LabelKeyResourcePoolId, LabelKeyOwnerId},
	)

	DeleteIdleResourcePoolRunsTotal = prometheus.NewCounter(
		prometheus.CounterOpts{
			Name: "delete_idle_resource_pool_runs_total",
			Help: "Total number of delete idle resource pools worker runs",
		},
	)

	DeleteIdleResourcePoolFailedTotal = prometheus.NewCounter(
		prometheus.CounterOpts{
			Name: "delete_idle_resource_pool_failed_total",
			Help: "Total number of delete idle resource pools failures",
		},
	)
)

func init() {
	// Register all metrics with Prometheus
	prometheus.MustRegister(
		CheckIdleWorkerRunsTotal,
		CheckIdleErrorTotal,
		IdleSeconds,
		DeleteIdleResourcePoolRunsTotal,
		DeleteIdleResourcePoolFailedTotal,
	)
}
