fix: metrics reduces labels (#1457)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
70ed392263
commit
812ff5557b
|
|
@ -70,6 +70,10 @@ const (
|
|||
OtelServiceName = "dragonfly-dfdaemon-object-storage"
|
||||
)
|
||||
|
||||
const (
|
||||
RouterGroupBuckets = "/buckets"
|
||||
)
|
||||
|
||||
var GinLogFileName = "gin-object-stroage.log"
|
||||
|
||||
const (
|
||||
|
|
@ -147,6 +151,15 @@ func (o *objectStorage) initRouter(cfg *config.DaemonOption, logDir string) *gin
|
|||
|
||||
// Prometheus metrics
|
||||
p := ginprometheus.NewPrometheus(PrometheusSubsystemName)
|
||||
// Prometheus metrics need to reduce label,
|
||||
// refer to https://prometheus.io/docs/practices/instrumentation/#do-not-overuse-labels.
|
||||
p.ReqCntURLLabelMappingFn = func(c *gin.Context) string {
|
||||
if strings.HasPrefix(c.Request.URL.Path, RouterGroupBuckets) {
|
||||
return RouterGroupBuckets
|
||||
}
|
||||
|
||||
return c.Request.URL.Path
|
||||
}
|
||||
p.Use(r)
|
||||
|
||||
// Opentelemetry
|
||||
|
|
@ -158,7 +171,7 @@ func (o *objectStorage) initRouter(cfg *config.DaemonOption, logDir string) *gin
|
|||
r.GET("/healthy", o.getHealth)
|
||||
|
||||
// Buckets
|
||||
b := r.Group("/buckets")
|
||||
b := r.Group(RouterGroupBuckets)
|
||||
b.HEAD(":id/objects/*object_key", o.headObject)
|
||||
b.GET(":id/objects/*object_key", o.getObject)
|
||||
b.DELETE(":id/objects/*object_key", o.destroyObject)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-http-utils/headers"
|
||||
|
|
@ -45,6 +46,10 @@ const (
|
|||
OtelServiceName = "dragonfly-dfdaemon-upload"
|
||||
)
|
||||
|
||||
const (
|
||||
RouterGroupDownload = "/download"
|
||||
)
|
||||
|
||||
var GinLogFileName = "gin-upload.log"
|
||||
|
||||
// Manager is the interface used for upload task.
|
||||
|
|
@ -124,6 +129,15 @@ func (um *uploadManager) initRouter(cfg *config.DaemonOption, logDir string) *gi
|
|||
|
||||
// Prometheus metrics
|
||||
p := ginprometheus.NewPrometheus(PrometheusSubsystemName)
|
||||
// Prometheus metrics need to reduce label,
|
||||
// refer to https://prometheus.io/docs/practices/instrumentation/#do-not-overuse-labels.
|
||||
p.ReqCntURLLabelMappingFn = func(c *gin.Context) string {
|
||||
if strings.HasPrefix(c.Request.URL.Path, RouterGroupDownload) {
|
||||
return RouterGroupDownload
|
||||
}
|
||||
|
||||
return c.Request.URL.Path
|
||||
}
|
||||
p.Use(r)
|
||||
|
||||
// Opentelemetry
|
||||
|
|
@ -135,7 +149,8 @@ func (um *uploadManager) initRouter(cfg *config.DaemonOption, logDir string) *gi
|
|||
r.GET("/healthy", um.getHealth)
|
||||
|
||||
// Peer download task.
|
||||
r.GET("/download/:task_prefix/:task_id", um.getDownload)
|
||||
d := r.Group(RouterGroupDownload)
|
||||
d.GET(":task_prefix/:task_id", um.getDownload)
|
||||
|
||||
return r
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,12 @@ func Init(cfg *config.Config, logDir string, service service.Service, enforcer *
|
|||
|
||||
// Prometheus metrics
|
||||
p := ginprometheus.NewPrometheus(PrometheusSubsystemName)
|
||||
// URL removes query string.
|
||||
// Prometheus metrics need to reduce label,
|
||||
// refer to https://prometheus.io/docs/practices/instrumentation/#do-not-overuse-labels.
|
||||
p.ReqCntURLLabelMappingFn = func(c *gin.Context) string {
|
||||
return c.Request.URL.Path
|
||||
}
|
||||
p.Use(r)
|
||||
|
||||
// Opentelemetry
|
||||
|
|
|
|||
Loading…
Reference in New Issue