package autoanalyze

import (
	"github.com/prometheus/client_golang/prometheus"
	"github.com/tidbcloud/aws-shared-provider/pkg/tidbworker/job"
	"github.com/tidbcloud/aws-shared-provider/pkg/tidbworker/metrics"
	"github.com/tidbcloud/aws-shared-provider/pkg/tidbworker/schema/autoanalyze"
)

var (
	runnerCounter        prometheus.Counter
	currentTaskCounter   map[autoanalyze.State]prometheus.Gauge
	taskCompleteDuration prometheus.Observer
	taskQueueDuration    prometheus.Observer
)

func initMetrics() {
	runnerCounter = metrics.RunnerCounter.WithLabelValues(string(job.TypeAutoAnalyze))
	currentTaskCounter = map[autoanalyze.State]prometheus.Gauge{
		autoanalyze.StatePending: metrics.CurrentTaskCounter.WithLabelValues(
			string(job.TypeAutoAnalyze), string(autoanalyze.StatePending)),
		autoanalyze.StateRunning: metrics.CurrentTaskCounter.WithLabelValues(
			string(job.TypeAutoAnalyze), string(autoanalyze.StateRunning)),
		autoanalyze.StateDone: metrics.CurrentTaskCounter.WithLabelValues(
			string(job.TypeAutoAnalyze), string(autoanalyze.StateDone)),
		autoanalyze.StatePaused: metrics.CurrentTaskCounter.WithLabelValues(
			string(job.TypeAutoAnalyze), string(autoanalyze.StatePaused)),
	}
	taskCompleteDuration = metrics.TaskCompleteDuration.WithLabelValues(string(job.TypeAutoAnalyze))
	taskQueueDuration = metrics.TaskQueueDuration.WithLabelValues(string(job.TypeAutoAnalyze))
}
