Forked from labstack/echo-contrib.
Original author: carlosedp
import "github.com/labstack/echo/v4"
import "github.com/aaronjan/echo-contrib/prometheus"
func urlSkipper(c echo.Context) bool {
if strings.HasPrefix(c.Path(), "/health-check") {
return true
}
return false
}
func main() {
e := echo.New()
additionMetrics := []*prometheus.Metric{&prometheus.Metric{
ID: "helloCnt",
Name: "hellos_total",
Description: "How many times this app says hello to users.",
Type: "summary",
}}
p := prometheus.NewPrometheusWithConfig(prometheus.Config{
MetricsPath: "/metrics",
Subsystem: "echo",
Skipper: urlSkipper,
AdditionMetrics: additionMetrics,
})
p.Embed(e)
e.Start()
}
import "context"
import "github.com/labstack/echo/v4"
import "github.com/aaronjan/echo-contrib/prometheus"
func urlSkipper(c echo.Context) bool {
if strings.HasPrefix(c.Path(), "/health-check") {
return true
}
return false
}
func main() {
e := echo.New()
additionMetrics := []*prometheus.Metric{&prometheus.Metric{
ID: "helloCnt",
Name: "hellos_total",
Description: "How many times this app says hello to users.",
Type: "summary",
}}
p := prometheus.NewPrometheusWithConfig(prometheus.Config{
MetricsPath: "/metrics",
Subsystem: "echo",
Skipper: urlSkipper,
AdditionMetrics: additionMetrics,
})
p.Mount(e)
pe := echo.New()
go p.Start(pe, ":1323")
// To stop: pe.Shutdown()
e.Start()
}