This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/server/handlers/admin_metrics.go
Jeffrey Smith 36d6158940
All checks were successful
CI/CD / detect-changes (push) Successful in 3s
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m42s
CI/CD / test-sqlite (push) Successful in 2m48s
CI/CD / build-and-deploy (push) Successful in 1m5s
Feat v0.6.4 health metrics (#39)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
2026-03-31 14:05:49 +00:00

25 lines
554 B
Go

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)
}