SEBA-794:update-exporter-for-promhttp
Change-Id: Ia16a5efc484dc27821873e09106bf3770d2b74fd
diff --git a/main.go b/main.go
index 3880e98..81b1635 100644
--- a/main.go
+++ b/main.go
@@ -18,6 +18,7 @@
"gerrit.opencord.org/kafka-topic-exporter/common/logger"
"github.com/Shopify/sarama"
"github.com/prometheus/client_golang/prometheus"
+ "github.com/prometheus/client_golang/prometheus/promhttp"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
@@ -66,8 +67,11 @@
target.Port = 8080
}
logger.Debug("Starting HTTP Server on %d port", target.Port)
- http.Handle("/metrics", prometheus.Handler())
- http.ListenAndServe(":"+strconv.Itoa(target.Port), nil)
+ http.Handle("/metrics", promhttp.Handler())
+ err := http.ListenAndServe(":"+strconv.Itoa(target.Port), nil)
+ if err != nil {
+ logger.Error("HTTP Server Error: %s", err.Error())
+ }
}
func init() {
@@ -130,4 +134,4 @@
go kafkaInit(conf.Broker)
runServer(conf.Target)
-}
\ No newline at end of file
+}