1
0

feat: add Prometheus metrics (#439)

* feat: add Prometheus metrics

* setup metrics using Prometheus client under /metrics endpoint
* add configuration value for metrics
* configure Prometheus middleware for generic metrics
* provide metrics for totals of users, gists and SSH keys
* modify test request to optionally return the response
* provide integration test for Prometheus metrics
* update documentation

* chore: make fmt
هذا الالتزام موجود في:
Philipp Eckel
2025-03-17 14:30:38 +01:00
ملتزم من قبل GitHub
الأصل 8c7e941182
التزام 1ec026e191
13 ملفات معدلة مع 328 إضافات و21 حذوفات

عرض الملف

@@ -3,6 +3,7 @@ package server
import (
"errors"
"fmt"
"github.com/labstack/echo-contrib/echoprometheus"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/rs/zerolog/log"
@@ -34,6 +35,10 @@ func (s *Server) useCustomContext() {
func (s *Server) registerMiddlewares() {
s.echo.Use(Middleware(dataInit).toEcho())
s.echo.Use(Middleware(locale).toEcho())
if config.C.MetricsEnabled {
p := echoprometheus.NewMiddleware("opengist")
s.echo.Use(p)
}
s.echo.Pre(middleware.MethodOverrideWithConfig(middleware.MethodOverrideConfig{
Getter: middleware.MethodFromForm("_method"),