Skip to content

Commit

Permalink
ref: set constant metrics endpoint
Browse files Browse the repository at this point in the history
no point in making it configurable
  • Loading branch information
wbollock committed Oct 10, 2023
1 parent 7ba16e6 commit cb5bbb1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const (

var (
listenAddress = flag.String("web.listen-address", defaultListenAddress, "Address to listen on for telemetry")
metricsPath = flag.String("web.telemetry-path", defaultMetricsPath, "Path under which to expose metrics")
showVersion = flag.Bool("version", false, "show version information")
logLevel = flag.String("log.level", defaultLogLevel,
"Minimum Log level [debug, info]")
Expand All @@ -45,7 +44,7 @@ func main() {
log.SetLevel(log.InfoLevel)
}

handler := server.SetupServer(*metricsPath)
handler := server.SetupServer()

log.Infof("Starting server on %s", *listenAddress)
if err := http.ListenAndServe(*listenAddress, handler); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const (
defaultMetricsPath = "/metrics"
)

func SetupServer(metricsPath string) http.Handler {
func SetupServer() http.Handler {
mux := http.NewServeMux()

mux.Handle(metricsPath, promhttp.Handler())
mux.Handle(defaultMetricsPath, promhttp.Handler())
mux.HandleFunc("/probe", collector.PingHandler)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
response := fmt.Sprintf(defaultHTML, metricsPath)
response := fmt.Sprintf(defaultHTML, defaultMetricsPath)
_, err := w.Write([]byte(response))
if err != nil {
log.WithError(err).Error("Failed to write main page response")
Expand Down

0 comments on commit cb5bbb1

Please sign in to comment.