Skip to content

jpbede/fasthttp-prometheus-middleware

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))

}

About

Prometheus middleware for fasthttp, fasthttp/router

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%