Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
Signed-off-by: André Bauer <[email protected]>
  • Loading branch information
monotek committed Jan 22, 2025
1 parent e2298fe commit 3a1ed3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 13 additions & 10 deletions cmd/pingdom-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/monotek/pingdom-exporter/pkg/pingdom-exporter"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

Expand All @@ -22,7 +23,6 @@ var (
token string
tags string
metricsPath string
waitSeconds int
port int
outageCheckPeriod int
defaultUptimeSLO float64
Expand Down Expand Up @@ -299,19 +299,22 @@ func main() {

registry.MustRegister(
collector,
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
prometheus.NewGoCollector(),
collectors.NewProcessCollector(prometheus.ProcessCollectorOpts{}),

Check failure on line 302 in cmd/pingdom-exporter/main.go

View workflow job for this annotation

GitHub Actions / go-lint

cannot use prometheus.ProcessCollectorOpts{} (value of type prometheus.ProcessCollectorOpts) as collectors.ProcessCollectorOpts value in argument to collectors.NewProcessCollector (typecheck)
collectors.NewGoCollector(),
)

http.Handle(metricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
<head><title>Pingdom Exporter</title></head>
<body>
<h1>Pingdom Exporter</h1>
<p><a href='` + metricsPath + `'>Metrics</a></p>
</body>
</html>`))
_, err := w.Write([]byte(`<html>
<head><title>Pingdom Exporter</title></head>
<body>
<h1>Pingdom Exporter</h1>
<p><a href='` + metricsPath + `'>Metrics</a></p>
</body>
</html>`))
if err != nil {
http.Error(w, "Unable to write response", http.StatusInternalServerError)
}
})

fmt.Fprintf(os.Stdout, "Pingdom Exporter %v listening on http://0.0.0.0:%v\n", VERSION, port)
Expand Down
4 changes: 3 additions & 1 deletion cmd/pingdom-exporter/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

func (s *Server) healthz(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
if _, err := w.Write([]byte("OK")); err != nil {
http.Error(w, "Unable to write response", http.StatusInternalServerError)
}
}

0 comments on commit 3a1ed3b

Please sign in to comment.