func (apm *ApplicationMetrics) SetNumberOfImagesWatched(application string, num int) {
	apm.imagesWatchedTotal.WithLabelValues(application).Set(float64(num))
}
SetNumberOfImagesWatched sets the total number of currently watched images for given application
package metrics
import (
	"fmt"
	"net/http"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promauto"
	"github.com/prometheus/client_golang/prometheus/promhttp"
)
var epm *EndpointMetrics
var apm *ApplicationMetrics
var cpm *ClientMetrics
type EndpointMetrics struct {
	requestsTotal  *prometheus.CounterVec
	requestsFailed *prometheus.CounterVec
}
type ApplicationMetrics struct {
	applicationsTotal        prometheus.Gauge
	imagesWatchedTotal       *prometheus.GaugeVec
	imagesUpdatedTotal       *prometheus.CounterVec
	imagesUpdatedErrorsTotal *prometheus.CounterVec
}
type ClientMetrics struct {
	argoCDRequestsTotal        *prometheus.CounterVec
	argoCDRequestsErrorsTotal  *prometheus.CounterVec
	kubeAPIRequestsTotal       prometheus.Counter
	kubeAPIRequestsErrorsTotal prometheus.Counter
}
func StartMetricsServer(port int) chan error {
	errCh := make(chan error)
	go func() {
		sm := http.NewServeMux()
		sm.Handle("/metrics", promhttp.Handler())
		errCh <- http.ListenAndServe(fmt.Sprintf(":%d", port), sm)
	}()
	return errCh
}
func NewEndpointMetrics() *EndpointMetrics {
	metrics := &EndpointMetrics{}
	metrics.requestsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "argocd_image_updater_registry_requests_total",
		Help: "The total number of requests to this endpoint",
	}, []string{"registry"})
	metrics.requestsFailed = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "argocd_image_updater_registry_requests_failed_total",
		Help: "The number of failed requests to this endpoint",
	}, []string{"registry"})
	return metrics
}
func NewApplicationsMetrics() *ApplicationMetrics {
	metrics := &ApplicationMetrics{}
	metrics.applicationsTotal = promauto.NewGauge(prometheus.GaugeOpts{
		Name: "argocd_image_updater_applications_watched_total",
		Help: "The total number of applications watched by Argo CD Image Updater",
	})
	metrics.imagesWatchedTotal = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Name: "argocd_image_updater_images_watched_total",
		Help: "Number of images watched by Argo CD Image Updater",
	}, []string{"application"})
	metrics.imagesUpdatedTotal = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "argocd_image_updater_images_updated_total",
		Help: "Number of images updates by Argo CD Image Updater",
	}, []string{"application"})
	metrics.imagesUpdatedErrorsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "argocd_image_updater_images_errors_total",
		Help: "Number of errors reported by Argo CD Image Updater",
	}, []string{"application"})
	return metrics
}
func NewClientMetrics() *ClientMetrics {
	metrics := &ClientMetrics{}
	metrics.argoCDRequestsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "argocd_image_updater_argocd_api_requests_total",
		Help: "The total number of Argo CD API requests performed by the Argo CD Image Updater",
	}, []string{"argocd_server"})
	metrics.argoCDRequestsErrorsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "argocd_image_updater_argocd_api_errors_total",
		Help: "The total number of Argo CD API requests resulting in error",
	}, []string{"argocd_server"})
	metrics.kubeAPIRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
		Name: "argocd_image_updater_k8s_api_requests_total",
		Help: "The total number of Argo CD API requests resulting in error",
	})
	metrics.kubeAPIRequestsErrorsTotal = promauto.NewCounter(prometheus.CounterOpts{
		Name: "argocd_image_updater_k8s_api_errors_total",
		Help: "The total number of Argo CD API requests resulting in error",
	})
	return metrics
}
func Endpoint() *EndpointMetrics {
	return epm
}
func Applications() *ApplicationMetrics {
	return apm
}
func Clients() *ClientMetrics {
	return cpm
}
func (epm *EndpointMetrics) IncreaseRequest(registryURL string, isFailed bool) {
	epm.requestsTotal.WithLabelValues(registryURL).Inc()
	if isFailed {
		epm.requestsFailed.WithLabelValues(registryURL).Inc()
	}
}
func (apm *ApplicationMetrics) SetNumberOfApplications(num int) {
	apm.applicationsTotal.Set(float64(num))
}