summaryrefslogtreecommitdiff
path: root/common/prometheus.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/prometheus.go')
-rw-r--r--common/prometheus.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/prometheus.go b/common/prometheus.go
new file mode 100644
index 0000000..f69854b
--- /dev/null
+++ b/common/prometheus.go
@@ -0,0 +1,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)
+ }
+}