2022-04-27 01:00:20 -05:00
|
|
|
//go:build !metrics
|
|
|
|
// +build !metrics
|
|
|
|
|
|
|
|
package extensions
|
|
|
|
|
|
|
|
import (
|
2023-09-15 06:49:34 -05:00
|
|
|
"net/http"
|
|
|
|
|
2022-04-27 01:00:20 -05:00
|
|
|
"github.com/gorilla/mux"
|
2022-10-20 11:39:20 -05:00
|
|
|
|
2022-04-27 01:00:20 -05:00
|
|
|
"zotregistry.io/zot/pkg/api/config"
|
2023-09-15 06:49:34 -05:00
|
|
|
zcommon "zotregistry.io/zot/pkg/common"
|
|
|
|
"zotregistry.io/zot/pkg/extensions/monitoring"
|
2022-04-27 01:00:20 -05:00
|
|
|
"zotregistry.io/zot/pkg/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// EnableMetricsExtension ...
|
|
|
|
func EnableMetricsExtension(config *config.Config, log log.Logger, rootDir string) {
|
|
|
|
log.Warn().Msg("skipping enabling metrics extension because given zot binary doesn't include this feature," +
|
|
|
|
"please build a binary that does so")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetupMetricsRoutes ...
|
|
|
|
func SetupMetricsRoutes(conf *config.Config, router *mux.Router,
|
2023-10-20 02:33:26 -05:00
|
|
|
authnFunc, authzFunc mux.MiddlewareFunc, log log.Logger, metrics monitoring.MetricServer,
|
2022-04-27 01:00:20 -05:00
|
|
|
) {
|
2023-09-15 06:49:34 -05:00
|
|
|
getMetrics := func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
m := metrics.ReceiveMetrics()
|
|
|
|
zcommon.WriteJSON(w, http.StatusOK, m)
|
|
|
|
}
|
|
|
|
|
2023-10-20 02:33:26 -05:00
|
|
|
router.Use(authnFunc)
|
|
|
|
router.Use(authzFunc)
|
2023-09-15 06:49:34 -05:00
|
|
|
router.HandleFunc("/metrics", getMetrics).Methods("GET")
|
2022-04-27 01:00:20 -05:00
|
|
|
}
|