fasthttpprom

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: MIT Imports: 7 Imported by: 0

README

fasthttp prometheus-middleware

Fasthttp fasthttp middleware for Prometheus

Export metrics for request duration request_duration and request count request_count

Example

using fasthttp/router

package main

import (
"log"

fasthttpprom "github.com/carousell/fasthttp-prometheus-middleware"
"github.com/fasthttp/router"
"github.com/valyala/fasthttp"
)

func main() {

	r := router.New()
	p := fasthttpprom.NewPrometheus("")
	p.Use(r)

	r.GET("/health", func(ctx *fasthttp.RequestCtx) {
		ctx.SetStatusCode(200)
		ctx.SetBody([]byte(`{"status": "pass"}`))
		log.Println(string(ctx.Request.URI().Path()))
	})

	log.Println("main is listening on ", "8080")
	log.Fatal(fasthttp.ListenAndServe(":"+"8080", p.Handler))

}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultBuckets = []float64{.005, .01, .02, 0.04, .06, 0.08, .1, 0.15, .25, 0.4, .6, .8, 1, 1.5, 2, 3, 5}
)

Functions

func NewMiddleware

func NewMiddleware(name, prefix string, buckets ...float64) func(handler fasthttp.RequestHandler) fasthttp.RequestHandler

NewMiddleware is

func PrometheusHandler

func PrometheusHandler() fasthttp.RequestHandler

Types

type Prometheus

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

Prometheus contains the metrics gathered by the instance and its path

Jump to

Keyboard shortcuts

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