echoprometheus

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

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

Go to latest
Published: Sep 24, 2019 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

echo-prometheus

A prometheus exporter for echo

GoDoc License

Install

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

Usage

package main

import (
	"github.com/0neSe7en/echo-prometheus"
	"github.com/labstack/echo"
	"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