New Prometheus middleware
Introduced new Prometheus middleware (#94 ). This is cleaner API to replace older (now deprecated) Prometheus middleware. See README.md for migration guide.
Short example:
package main
import (
"errors"
"github.com/labstack/echo-contrib/echoprometheus"
"github.com/labstack/echo/v4"
"log"
"net/http"
)
func main() {
e := echo.New()
e.Use(echoprometheus.NewMiddleware("myapp")) // Add metrics middleware
e.GET("/metrics", echoprometheus.NewHandler()) // Add handler for metrics scrapers
if err := e.Start(":8080"); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Fatal(err)
}
}