metrics.go 569 B

12345678910111213141516171819202122232425
  1. package fiber
  2. import (
  3. "fmt"
  4. "github.com/gofiber/fiber/v2"
  5. "github.com/gofiber/fiber/v2/middleware/basicauth"
  6. "github.com/gofiber/fiber/v2/middleware/monitor"
  7. )
  8. func initMetrics(app *fiber.App, sp ServiceProvider) {
  9. basicAuth := basicauth.New(basicauth.Config{
  10. Users: map[string]string{
  11. sp.ConfigService().BasicAuthUser(): sp.ConfigService().BasicAuthPassword(),
  12. },
  13. })
  14. app.Get(metricsURI, basicAuth, monitor.New(getMetricsConfig()))
  15. }
  16. func getMetricsConfig() monitor.Config {
  17. return monitor.Config{
  18. Title: fmt.Sprintf("%s metrics", appName),
  19. }
  20. }