All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-frontend (pull_request) Successful in 5s
CI/CD / test-sqlite (pull_request) Successful in 2m54s
CI/CD / test-go-pg (pull_request) Successful in 2m56s
CI/CD / build-and-deploy (pull_request) Successful in 1m1s
Clean up channels-era dead code, align migrations, add 92 tests, and fix backup download + admin storage tab bugs before v0.8.x kernel expansion. Critical fixes: - Remove `channels` from allowedViews in db_module.go - Fix 5 dead API routes in workflow.html → public workflow API - Fix RenderWorkflow handler to use route param as entry token Dead code removal: - Delete SeedTestChannel(), RunContext.ChannelID, webhook.ChannelID - Fix stale comments in storage.go, prometheus.go, workflow_module.go Migration hygiene: - Add SQLite placeholder 013_cluster_registry.sql, renumber to 014 - Compat rename in migrate.go for existing SQLite databases - Document missing migration 008 in both 009 files Test coverage: - 82 workflow routing tests (all operators, branch rules, stage resolution) - 10 middleware tests (permissions, admin, rate limiter) Bug fixes: - Remove dead Admin Storage tab from System category - Fix backup download: sw.auth.token() → sw.auth._getToken() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
31 lines
746 B
Go
31 lines
746 B
Go
package middleware
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"armature/metrics"
|
|
)
|
|
|
|
// Prometheus returns a Gin middleware that records HTTP request metrics.
|
|
// Uses c.FullPath() (Gin's registered route pattern, e.g.
|
|
// "/api/v1/workflows/:id") to avoid label cardinality explosion from
|
|
// path parameters.
|
|
func Prometheus() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
start := time.Now()
|
|
c.Next()
|
|
|
|
pattern := c.FullPath()
|
|
if pattern == "" {
|
|
pattern = "unmatched"
|
|
}
|
|
status := strconv.Itoa(c.Writer.Status())
|
|
|
|
metrics.HTTPRequestsTotal.WithLabelValues(c.Request.Method, pattern, status).Inc()
|
|
metrics.HTTPRequestDuration.WithLabelValues(c.Request.Method, pattern).Observe(time.Since(start).Seconds())
|
|
}
|
|
}
|