package metric

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

const (
	TenantLabel       = "tenant"
	TenantNameLabel   = "tenant_name"
	ClusterIDLabel    = "cluster_id"
	ClusterNameLabel  = "cluster_name"
	ProviderTypeLabel = "provider_type"
)

// CommonLabels define some common labels to help diagnose problems
var (
	CommonLabels = []string{TenantLabel, TenantNameLabel, ClusterIDLabel, ClusterNameLabel}
)

var (
	SyncingImportSinceCreatedSeconds = prometheus.NewDesc(
		prometheus.BuildFQName(MetricNamespace, "import", "syncing_import_since_created_seconds"),
		"How long has the import been created still syncing",
		[]string{"tenant", ClusterIDLabel, "import_id", ProviderTypeLabel, "status"},
		nil)

	ImportSizeWithIndexBytes = prometheus.NewDesc(
		prometheus.BuildFQName(MetricNamespace, "import", "size_with_index_bytes"),
		"Import size with index in bytes",
		[]string{"tenant", ClusterIDLabel, "import_id", ProviderTypeLabel, "status"},
		nil)

	RecentFailImports = prometheus.NewDesc(
		prometheus.BuildFQName(MetricNamespace, "import", "fail"),
		"Recent failed imports",
		[]string{"tenant", ClusterIDLabel, "import_id", ProviderTypeLabel, "msg", "tenant_plan", "tenant_kind"},
		nil)

	ImportThroughputBytes = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: MetricNamespace,
			Subsystem: "import",
			Name:      "throughput_bytes",
			Help:      "Import job throughput in bytes/s",
			Buckets:   prometheus.ExponentialBuckets(1024, 2, 22), // 1KB/s-4GB/s
		}, []string{ProviderTypeLabel})
)

func init() {
	prometheus.MustRegister(ImportThroughputBytes)
}
