echoprometheus

package module
v0.0.0-...-e1a57ac Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: MIT Imports: 5 Imported by: 0

README

echo-prometheus

A prometheus exporter for echo

GoDoc License

Install

$ go get github.com/0neSe7en/echo-prometheus

Usage

package main

import (
	"github.com/ghiac/echo-v4-prometheus"
	"github.com/labstack/echo/v4"
	"github.com/prometheus/client_golang/prometheus/promhttp"
)

func main() {
	e := echo.New()

	e.Use(echoprometheus.NewMetric())
	e.GET("/metrics", echo.WrapHandler(promhttp.Handler()))
	// Routes
	e.GET("/", hello)

	// Start server
	e.Logger.Fatal(e.Start(":1323"))
}

// Handler
func hello(c echo.Context) error {
	return c.String(http.StatusOK, "Hello, World!")
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPrometheusConfig supplies Prometheus client with the default
	// skipper and the 'echo' namespace.
	DefaultPrometheusConfig = PrometheusConfig{
		Skipper:   middleware.DefaultSkipper,
		Namespace: "echo",
	}
)

Functions

func NewMetric

func NewMetric() echo.MiddlewareFunc

NewMetric returns an echo middleware with the default configuration.

func NewMetricWithConfig

func NewMetricWithConfig(config PrometheusConfig) echo.MiddlewareFunc

NewMetricWithConfig returns an echo middleware with a custom configuration.

Types

type PrometheusConfig

type PrometheusConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper

	// Namespace is single-word prefix relevant to the domain the metric
	// belongs to. For metrics specific to an application, the prefix is
	// usually the application name itself.
	Namespace string
}

PrometheusConfig contains the configuation for the echo-prometheus middleware.

Jump to

Keyboard shortcuts

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