add monitoring #4
@@ -4,6 +4,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -115,7 +116,7 @@ func MetricsMiddleware() gin.HandlerFunc {
|
|||||||
httpRequestDuration.WithLabelValues(method, path).Observe(duration)
|
httpRequestDuration.WithLabelValues(method, path).Observe(duration)
|
||||||
|
|
||||||
// Record API-specific metrics for API routes
|
// 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()
|
apiRequestsTotal.WithLabelValues(path, method).Inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user