Feat v0.6.4 health metrics (#39)
All checks were successful
All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #39.
This commit is contained in:
24
server/handlers/admin_metrics.go
Normal file
24
server/handlers/admin_metrics.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"switchboard-core/metrics"
|
||||
)
|
||||
|
||||
// MetricsHandler serves the admin metrics endpoint.
|
||||
type MetricsHandler struct {
|
||||
collector *metrics.Collector
|
||||
}
|
||||
|
||||
// NewMetricsHandler creates a MetricsHandler.
|
||||
func NewMetricsHandler(c *metrics.Collector) *MetricsHandler {
|
||||
return &MetricsHandler{collector: c}
|
||||
}
|
||||
|
||||
// GetMetrics returns a full metrics snapshot.
|
||||
// GET /api/v1/admin/metrics
|
||||
func (h *MetricsHandler) GetMetrics(c *gin.Context) {
|
||||
snap := h.collector.Collect(c.Request.Context())
|
||||
c.JSON(200, snap)
|
||||
}
|
||||
Reference in New Issue
Block a user