summaryrefslogtreecommitdiff
path: root/gateway/lib/prometheus.go
blob: 98d7371226a8c7d3fa67e4db12a78c01719b8f39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package lib

import (
	"fmt"
	"net/http"

	"github.com/prometheus/client_golang/prometheus/promhttp"
	"github.com/rs/zerolog/log"
)

// CreatePrometheus creates a webserver instance that returns the metrics of the
// current program reported using promauto.
func CreatePrometheus(port int) {
	http.Handle("/metrics", promhttp.Handler())
	err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)

	if err != nil {
		log.Err(err).Msgf("failed to start the prometheus reporting on the port :%d", port)
	}
}