Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Ly Phuc Linh committed Apr 5, 2022
1 parent b8441f9 commit 270b22a
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
# fasthttp prometheus-middleware
Fasthttp [fasthttp](https://github.com/valyala/fasthttp) middleware for Prometheus
# fiber prometheus-middleware
[Fiber](https://gofiber.io/) middleware for Prometheus

Export metrics for request duration ```request_duration``` and request count ```request_count```

## Example
using fasthttp/router
using fiber

package main
```go
package main

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

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

func main() {
func main() {

r := router.New()
p := fasthttpprom.NewPrometheus("")
p.Use(r)
r := fiber.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()))
})
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 ", "8080")
log.Fatal(fasthttp.ListenAndServe(":"+"8080", p.Handler))

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

}

```

0 comments on commit 270b22a

Please sign in to comment.