package metrics

import (
	"github.com/prometheus/client_golang/prometheus"
	_ "github.com/zsais/go-gin-prometheus"
)

// @Time    : 2022/11/25 4:18 PM
// @Author  : lvhongmeng

var (
	//HTTPReqDuration metric:http_request_duration_seconds
	HTTPReqDuration *prometheus.HistogramVec
	//HTTPReqTotal metric:http_request_total
	HTTPReqTotal *prometheus.CounterVec
)

func init() {
	// latency
	HTTPReqDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "sqleditor_http_request_duration_seconds",
		Help:    "The HTTP request latencies in seconds.",
		Buckets: nil,
	}, []string{"method", "path"})
	// count
	HTTPReqTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "sqleditor_http_requests_total",
		Help: "Total number of HTTP requests made.",
	}, []string{"method", "path", "status"})
	prometheus.MustRegister(
		HTTPReqDuration,
		HTTPReqTotal,
	)
}

// gin-promethues
//func RegisterMetricsRoute(r *gin.Engine) {
//	p := ginprometheus.NewPrometheus("sqleditor")
//	p.ReqCntURLLabelMappingFn = func(c *gin.Context) string {
//		return c.FullPath()
//	}
//	p.Use(r)
//}
