fix(metrics): properly surface errors with the metrics server

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2026-04-22 19:15:22 -04:00
parent 63e6a15280
commit b66630df74
+7 -1
View File
@@ -21,10 +21,16 @@ type Server struct {
Log *slog.Logger Log *slog.Logger
} }
func (s *Server) Run(ctx context.Context, done func()) error { func (s *Server) Run(ctx context.Context, done func()) {
defer done() defer done()
lg := s.Log.With("subsystem", "metrics") lg := s.Log.With("subsystem", "metrics")
if err := s.run(ctx, lg); err != nil {
lg.Error("can't serve metrics server", "err", err)
}
}
func (s *Server) run(ctx context.Context, lg *slog.Logger) error {
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("GET /debug/pprof/", pprof.Index) mux.HandleFunc("GET /debug/pprof/", pprof.Index)
mux.HandleFunc("GET /debug/pprof/cmdline", pprof.Cmdline) mux.HandleFunc("GET /debug/pprof/cmdline", pprof.Cmdline)