mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 20:38:08 +08:00
refactor: Review metrics endpoints (#1770)
Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
@@ -340,6 +340,10 @@ func isOpenIDAuthProviderEnabled(config *Config, provider string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Config) IsMetricsEnabled() bool {
|
||||
return c.Extensions != nil && c.Extensions.Metrics != nil && *c.Extensions.Metrics.Enable
|
||||
}
|
||||
|
||||
func (c *Config) IsSearchEnabled() bool {
|
||||
return c.Extensions != nil && c.Extensions.Search != nil && *c.Extensions.Search.Enable
|
||||
}
|
||||
|
||||
+1
-18
@@ -179,20 +179,8 @@ func (rh *RouteHandler) SetupRoutes() {
|
||||
// gql playground
|
||||
gqlPlayground.SetupGQLPlaygroundRoutes(prefixedRouter, rh.c.StoreController, rh.c.Log)
|
||||
|
||||
// setup extension routes
|
||||
if rh.c.Config != nil {
|
||||
// This logic needs to be reviewed, it should depend on build options
|
||||
// not the general presence of the extensions in config
|
||||
if rh.c.Config.Extensions == nil {
|
||||
// minimal build
|
||||
prefixedRouter.HandleFunc("/metrics", rh.GetMetrics).Methods("GET")
|
||||
} else {
|
||||
// extended build
|
||||
ext.SetupMetricsRoutes(rh.c.Config, rh.c.Router, authHandler, rh.c.Log)
|
||||
}
|
||||
}
|
||||
|
||||
// Preconditions for enabling the actual extension routes are part of extensions themselves
|
||||
ext.SetupMetricsRoutes(rh.c.Config, rh.c.Router, authHandler, rh.c.Log, rh.c.Metrics)
|
||||
ext.SetupSearchRoutes(rh.c.Config, prefixedRouter, rh.c.StoreController, rh.c.MetaDB, rh.c.CveInfo,
|
||||
rh.c.Log)
|
||||
ext.SetupImageTrustRoutes(rh.c.Config, prefixedRouter, rh.c.MetaDB, rh.c.Log)
|
||||
@@ -1860,11 +1848,6 @@ func (rh *RouteHandler) OpenIDCodeExchangeCallback() rp.CodeExchangeUserinfoCall
|
||||
}
|
||||
}
|
||||
|
||||
func (rh *RouteHandler) GetMetrics(w http.ResponseWriter, r *http.Request) {
|
||||
m := rh.c.Metrics.ReceiveMetrics()
|
||||
zcommon.WriteJSON(w, http.StatusOK, m)
|
||||
}
|
||||
|
||||
// helper routines
|
||||
|
||||
func getContentRange(r *http.Request) (int64 /* from */, int64 /* to */, error) {
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ func SessionLogger(ctlr *Controller) mux.MiddlewareFunc {
|
||||
path = path + "?" + raw
|
||||
}
|
||||
|
||||
if path != "/v2/metrics" {
|
||||
if path != "/metrics" {
|
||||
// In order to test metrics feture,the instrumentation related to node exporter
|
||||
// should be handled by node exporter itself (ex: latency)
|
||||
monitoring.IncHTTPConnRequests(ctlr.Metrics, method, strconv.Itoa(statusCode))
|
||||
|
||||
Reference in New Issue
Block a user