Skip to content

New Prometheus middleware

Compare
Choose a tag to compare
@aldas aldas released this 22 May 12:57
· 12 commits to master since this release
c764849

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)
	}
}