Skip to content

Commit 48e3645

Browse files
authored
rename main.go to ipvs_exporter.go (#3)
* chore: rename ipvs_exporter.go Signed-off-by: kwanhur <[email protected]>
1 parent 5b2fa44 commit 48e3645

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

main.go ipvs_exporter.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ var (
2121
)
2222

2323
func init() {
24-
prometheus.Register(version.NewCollector("ipvs_exporter"))
24+
err := prometheus.Register(version.NewCollector("ipvs_exporter"))
25+
if err != nil {
26+
logrus.Fatalf("register ipvs_exporter failed:%s", err)
27+
}
2528
}
2629

2730
func main() {
@@ -33,7 +36,11 @@ func main() {
3336
}
3437
logrus.Infof("Starting ipvs_exporter %s", version.Info())
3538
logrus.Infof("Build context %s", version.BuildContext())
36-
prometheus.Register(NewIpvsCollector(*metricNamespace))
39+
40+
err := prometheus.Register(NewIpvsCollector(*metricNamespace))
41+
if err != nil {
42+
logrus.Fatalf("register collector %s failed:%s", *metricNamespace, err)
43+
}
3744

3845
if !*goMetrics {
3946
prometheus.Unregister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{
@@ -49,13 +56,16 @@ func main() {
4956

5057
http.Handle(*metricPath, promhttp.Handler())
5158
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
52-
writer.Write([]byte(`<html>
59+
_, err := writer.Write([]byte(`<html>
5360
<head><title>Ipvs Exporter</title></head>
5461
<body>
5562
<h1>Ipvs Exporter</h1>
5663
<p><a href="` + *metricPath + `">Metrics</a></p>
5764
</body>
5865
</html>`))
66+
if err != nil {
67+
logrus.Fatalf("handle request failed:%s", err)
68+
}
5969
})
6070

6171
if err := http.ListenAndServe(*listenAddress, nil); err != nil {

0 commit comments

Comments
 (0)