package metric

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

const (
	PullRequestEvent = "PullRequestEvent"
	CheckRunEvent    = "CheckRunEvent"

	UnknownAction = "unknown"
)

const (
	UnknownPanic      = "unknown panic"
	UnmarshallPayload = "unmarshall payload"
	HandlePullRequest = "handle pull request"
	HandleCheckRun    = "handle check run"

	MatchBranch  = "branch match"
	CreateBranch = "branch create"
	DeleteBranch = "branch delete"
	ResetBranch  = "branch reset"

	GitUpdateCheckRun = "git update check run"
	GitCommentBranch  = "git comment branch"
	GitGetContents    = "git get config"
	GitCommentError   = "git comment error"
)

var GitHubAppErrorCounter = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Namespace: "ecosystem_service",
		Subsystem: "github_app",
		Name:      "error_total",
		Help:      "the total of error",
	}, []string{"event", "action", "type"},
)

var GitConnectionGauge = prometheus.NewGaugeVec(
	prometheus.GaugeOpts{
		Namespace: "ecosystem_service",
		Subsystem: "github_app",
		Name:      "connection_number",
		Help:      "the number of connection",
	}, []string{"type"},
)

var GitHupAppTaskGauge = prometheus.NewGaugeVec(
	prometheus.GaugeOpts{
		Namespace: "ecosystem_service",
		Subsystem: "github_app",
		Name:      "task_number",
		Help:      "the number of github app task",
	}, []string{"status"},
)

func init() {
	prometheus.MustRegister(GitHubAppErrorCounter)
	prometheus.MustRegister(GitConnectionGauge)
	prometheus.MustRegister(GitHupAppTaskGauge)
}
