echo

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2020 License: MIT Imports: 0 Imported by: 0

README

Echo Contribution

Forked from labstack/echo-contrib.

GoDoc License

Packages

prometheus

Original author: carlosedp

Embed Prometheus into an Existent Echo Instance
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()
}
Start Prometheus in a Separate Echo Instance
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)

    ctx := context.Background()
    p.Start(ctx, echo.New(), ":1323")
    // To stop: ctx.Done() <- nil

    e.Start()
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package prometheus provides middleware to add Prometheus metrics.
Package prometheus provides middleware to add Prometheus metrics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL