Skip to content

Commit

Permalink
fix metric (#51)
Browse files Browse the repository at this point in the history
* fix metric

* fix: barry 2024-11-14 21:28:52
  • Loading branch information
kooksee authored Nov 14, 2024
1 parent 2030127 commit 4a664ef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ require (
github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19
github.com/maragudk/gomponents v0.20.0
github.com/prometheus/common v0.48.0
github.com/pubgo/dix v0.3.18
github.com/pubgo/funk v0.5.52
github.com/pubgo/dix v0.3.19
github.com/pubgo/funk v0.5.56
github.com/pubgo/protobuild v0.0.21
github.com/rs/xid v1.5.0
github.com/rs/zerolog v1.33.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,10 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/pubgo/dix v0.3.18 h1:s7qkJUEuajBF3GhqucE6lv4pDXvfgfZ8CQaFUHnjXWY=
github.com/pubgo/dix v0.3.18/go.mod h1:J0PyuMm7mW6ZrN13l9xz0rtKbzliREFyvb7fuaGYyVw=
github.com/pubgo/funk v0.5.52 h1:u/W7z3i+P6p/QV7mV5vL+OV9SxXPKo1OhQWCPOegAcc=
github.com/pubgo/funk v0.5.52/go.mod h1:kNSD071m7wU4ZXqsE15hqRobC0Pig7HI9Yil+3BESMc=
github.com/pubgo/dix v0.3.19 h1:a4RRmljw7ePUvc9uJKqXXs6JpYL8s3VqPP2NV2vxI9U=
github.com/pubgo/dix v0.3.19/go.mod h1:J0PyuMm7mW6ZrN13l9xz0rtKbzliREFyvb7fuaGYyVw=
github.com/pubgo/funk v0.5.56 h1:LYpjOBDSSeTorRWda0lmf23sJNDm6ZtbbNS0xQjb1CE=
github.com/pubgo/funk v0.5.56/go.mod h1:uAs5IQDz6ovr5zy4LC0Uq7No/eTIbeloSCjF0EQJesw=
github.com/pubgo/opendoc v0.0.5 h1:aM6xkBQ0XMSq8OWytl5JhTMBUv8L+aYQFXd2z9eNkZE=
github.com/pubgo/opendoc v0.0.5/go.mod h1:uO//pJZTJNFEKGuGWrv51/of0EoyxO1il4MuoC3Enp0=
github.com/pubgo/protobuild v0.0.21 h1:QSwh92QxsD6Mv7kQlowzE7fxtcOm1eMWmgADsD803Js=
Expand Down
12 changes: 0 additions & 12 deletions internal/middlewares/middleware_metric/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"time"

"github.com/pubgo/funk/generic"
"github.com/pubgo/funk/running"
"github.com/pubgo/lava/core/lavacontexts"
"github.com/uber-go/tally/v4"

"github.com/pubgo/lava/core/metrics"
Expand Down Expand Up @@ -54,16 +52,6 @@ func (m MetricMiddleware) Middleware(next lava.HandlerFunc) lava.HandlerFunc {

grpcServerRpcCallTotal(m.m, req.Operation())

clientInfo := lavacontexts.GetClientInfo(ctx)
if !req.Client() && clientInfo != nil {
m.m.Tagged(metrics.Tags{
"server_name": running.Project,
"server_method": req.Operation(),
"client_name": clientInfo.GetName(),
"client_method": clientInfo.GetPath(),
}).Counter("grpc_server_info").Inc(1)
}

defer func() {
if !generic.IsNil(gErr) {
grpcServerRpcErrTotal(m.m, req.Operation())
Expand Down
2 changes: 1 addition & 1 deletion servers/grpcs/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type httpRequest struct {

func (r *httpRequest) Kind() string { return "http" }
func (r *httpRequest) Operation() string {
return fmt.Sprintf("%s %s", strings.TrimSpace(r.ctx.Method()), strings.TrimSpace(r.ctx.Path()))
return fmt.Sprintf("%s %s", strings.TrimSpace(r.ctx.Method()), strings.TrimSpace(r.ctx.Route().Path))
}
func (r *httpRequest) Client() bool { return false }
func (r *httpRequest) Header() *lava.RequestHeader { return &r.ctx.Request().Header }
Expand Down

0 comments on commit 4a664ef

Please sign in to comment.