package br

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

func init() {
	prometheus.MustRegister(LightweightRestoreUnretryableErrorTotal)
	prometheus.MustRegister(ClassicRestoreUnretryableErrorTotal)
	prometheus.MustRegister(ManualBackupUnretryableErrorTotal)
	prometheus.MustRegister(FlushWALFailureTotal)
}

const (
	LabelErrorType    = "error_type"
	LabelSharedPoolId = "shared_pool_id"
	LabelRestoreId    = "restore_id"
	LabelBackupId     = "backup_id"
	LabelClusterId    = "cluster_id"

	ErrorTypePackBackup        = "pack_backup"
	ErrorTypeRestorePacked     = "restore_packed"
	ErrorTypeRestore           = "restore"
	ErrorTypeRestoreConflict   = "restore_conflict"
	ErrorTypeGetPitrBackupInfo = "get_pitr_backup_info"
	ErrorTypePackBackupBug     = "pack_backup_bug"
	ErrorTypeCopyBackup        = "copy_backup"
)

var (
	LightweightRestoreUnretryableErrorTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "lightweight_restore_unretryable_error_total",
			Help: "Lightweight restore error total",
		}, []string{LabelRestoreId, LabelErrorType})
	ClassicRestoreUnretryableErrorTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "classic_restore_unretryable_error_total",
			Help: "Classic restore error total",
		}, []string{LabelRestoreId, LabelErrorType})

	ManualBackupUnretryableErrorTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "manual_backup_unretryable_error_total",
			Help: "Manual backup error total",
		}, []string{LabelClusterId, LabelBackupId, LabelErrorType})

	FlushWALFailureTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "flush_wal_failure_total",
			Help: "Flush WAL failure total",
		}, []string{LabelSharedPoolId})
)
