blob: f69854b0e4db855f8d7191548be81ce91ad50aeb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package common
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)
}
}
|