Skip to content

Commit

Permalink
Merge pull request #18 from blockpane/develop
Browse files Browse the repository at this point in the history
Prometheus should use it's own servemux/server
  • Loading branch information
blockpane committed Jul 2, 2022
2 parents e695c35 + 6bf5dc7 commit e4984d1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions td2/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"net/http"
"sync"
"time"
)

var (
Expand Down Expand Up @@ -156,7 +157,17 @@ func prometheusExporter(ctx context.Context, updates chan *promUpdate) {
}
}()

promMux := http.NewServeMux()

l("serving prometheus metrics at 0.0.0.0:%d/metrics", td.PrometheusListenPort)
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", td.PrometheusListenPort), nil))
promMux.Handle("/metrics", promhttp.Handler())
promSrv := &http.Server{
Addr: fmt.Sprintf(":%d", td.PrometheusListenPort),
Handler: promMux,
ReadTimeout: 20 * time.Second,
WriteTimeout: 20 * time.Second,
IdleTimeout: 120 * time.Second,
ReadHeaderTimeout: 20 * time.Second,
}
log.Fatal(promSrv.ListenAndServe())
}

0 comments on commit e4984d1

Please sign in to comment.