add monitoring #4
@@ -4,6 +4,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -115,7 +116,7 @@ func MetricsMiddleware() gin.HandlerFunc {
|
||||
httpRequestDuration.WithLabelValues(method, path).Observe(duration)
|
||||
|
||||
// Record API-specific metrics for API routes
|
||||
if c.Request.URL.Path[:4] == "/api" {
|
||||
if strings.HasPrefix(c.Request.URL.Path, "/api") {
|
||||
apiRequestsTotal.WithLabelValues(path, method).Inc()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user