fiberprom

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

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 7 Imported by: 0

README

fiber prometheus-middleware

Fiber middleware for Prometheus

Export metrics for request duration request_duration and request count request_count

Example

using fiber

package main

import (
	"github.com/gofiber/fiber/v2"
	"log"

	fiberprom "github.com/carousell/fiber-prometheus-middleware"
)

func main() {

	r := fiber.New()
	p := fiberprom.NewPrometheus("")
	p.Use(r)

	r.Get("/health", func(ctx *fiber.Ctx) error {
		ctx.Status(200)
		log.Println(string(ctx.Request().URI().Path()))
		return ctx.JSON(map[string]string{"status": "pass"})
	})

	log.Println("main is listening on ", "8081")
	log.Fatal(r.Listen(":8081"))

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prometheus

type Prometheus struct {
	MetricsPath string
	// contains filtered or unexported fields
}

Prometheus contains the metrics gathered by the instance and its path

func NewPrometheus

func NewPrometheus(subsystem string) *Prometheus

NewPrometheus generates a new set of metrics with a certain subsystem name

func (*Prometheus) HandlerFunc

func (p *Prometheus) HandlerFunc() fiber.Handler

HandlerFunc is onion or wrapper to handler for fasthttp listenandserve

func (*Prometheus) Use

func (p *Prometheus) Use(r fiber.Router)

Use adds the middleware to a fiber

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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