Skip to content

Commit

Permalink
Added a v2 suffix to the module path
Browse files Browse the repository at this point in the history
  • Loading branch information
Cengizhan Çalışkan authored and baris committed May 11, 2021
1 parent 7c0735d commit d3d3398
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Middleware for go fiber v2.x

## Installation
```bash
go get github.com/hepsiburada/fiber-prometheus
go get github.com/hepsiburada/fiber-prometheus/v2
```

## Examples
Expand All @@ -13,7 +13,7 @@ package main

import (
"github.com/gofiber/fiber/v2"
"github.com/hepsiburada/fiber-prometheus"
fiberprometheus "github.com/hepsiburada/fiber-prometheus/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/gofiber/fiber/v2"
fiberprometheus "github.com/hepsiburada/fiber-prometheus"
fiberprometheus "github.com/hepsiburada/fiber-prometheus/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/hepsiburada/fiber-prometheus
module github.com/hepsiburada/fiber-prometheus/v2

go 1.14

Expand Down
6 changes: 3 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Middleware struct {

func (m *Middleware) PrometheusHandler() fiber.Handler {
return func(c *fiber.Ctx) error {
if c.Path() == m.MetricPath {
if string(c.Context().Path()) == m.MetricPath {
return c.Next()
}

Expand All @@ -34,8 +34,8 @@ func (m *Middleware) PrometheusHandler() fiber.Handler {
statusCode := strconv.Itoa(c.Context().Response.StatusCode())
elapsed := float64(time.Since(start)) / float64(time.Second)

m.reqCount.WithLabelValues(statusCode, c.Method(), r.Path).Inc()
m.reqDuration.WithLabelValues(c.Method(), r.Path).Observe(elapsed)
m.reqCount.WithLabelValues(statusCode, string(c.Context().Method()), r.Path).Inc()
m.reqDuration.WithLabelValues(string(c.Context().Method()), r.Path).Observe(elapsed)
return nil
}
}
Expand Down

0 comments on commit d3d3398

Please sign in to comment.