Fix: Register /metrics endpoint handler in platform metrics router
The metrics endpoint was showing 404 because the HTTP handler was not being registered in initMetricsRouter(). Added MetricsHandlerProvider interface to check if metrics implementation provides a handler, and register it automatically. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0c9610520e
commit
a9c33b44eb
@ -136,6 +136,11 @@ func (pm *platformMetrics) startMetricsServer() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MetricsHandlerProvider is an interface for metrics implementations that can provide an HTTP handler
|
||||
type MetricsHandlerProvider interface {
|
||||
Handler() http.Handler
|
||||
}
|
||||
|
||||
func (pm *platformMetrics) initMetricsRouter() error {
|
||||
pm.router = mux.NewRouter()
|
||||
runtime.SetBlockProfileRate(*pm.cfgFn().MetricsSettings.BlockProfileRate)
|
||||
@ -170,6 +175,14 @@ func (pm *platformMetrics) initMetricsRouter() error {
|
||||
pm.router.HandleFunc("/", rootHandler)
|
||||
pm.router.StrictSlash(true)
|
||||
|
||||
// Register /metrics handler if metrics implementation provides a handler
|
||||
if pm.metricsImpl != nil {
|
||||
if handlerProvider, ok := pm.metricsImpl.(MetricsHandlerProvider); ok {
|
||||
pm.router.Handle("/metrics", handlerProvider.Handler())
|
||||
pm.logger.Info("Metrics endpoint registered at /metrics")
|
||||
}
|
||||
}
|
||||
|
||||
pm.router.Handle("/debug", http.RedirectHandler("/", http.StatusMovedPermanently))
|
||||
pm.router.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
pm.router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user