package metric

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

	"github.com/tidbcloud/tidb-management-service/utilities/workflow"
)

var (
	DagExecDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: workflow.NS,
			Name:      "dag_duration_seconds",
			Help:      "Duration of a workflow dag execution. Only recorded when the dag succeeds.",
			Buckets:   prometheus.ExponentialBucketsRange(1, 60*60*3, 10), // 1s to 3h
		},
		[]string{
			"tenant_id",
			"project_id",
			"target_region",
			"target_provider",
			"workflow_dag", // dag_id of dag_instances table
		})

	// TODO(@yifan): record the duration of each task in the dag.
	TaskExecDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: workflow.NS,
			Name:      "task_duration_seconds",
			Help:      "Duration of a workflow task execution. Only recorded when the task succeeds.",
			Buckets:   prometheus.ExponentialBucketsRange(1, 60*60*3, 10), // 1s to 3h
		},
		[]string{
			"tenant_id",
			"project_id",
			"target_region",
			"target_provider",
			"workflow_dag",    // dag_id of dag_instances table
			"workflow_task",   // task_id of task_instances table
			"workflow_action", // action_name of task_instances table
		})
)
