Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.

Commit c0b8968

Browse files
committed
Add gRPC method to call metrics
Signed-off-by: Rodrigo Chacon <[email protected]>
1 parent b09bb8d commit c0b8968

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cmd/rr-grpc/grpc/metrics.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ func newCollector() *metricCollector {
7373
Name: "rr_grpc_call_total",
7474
Help: "Total number of handled grpc requests after server restart.",
7575
},
76-
[]string{"code"},
76+
[]string{"code", "method"},
7777
),
7878
callDuration: prometheus.NewHistogramVec(
7979
prometheus.HistogramOpts{
8080
Name: "rr_grpc_call_duration_seconds",
8181
Help: "GRPC call duration.",
8282
},
83-
[]string{"code"},
83+
[]string{"code", "method"},
8484
),
8585
workersMemory: prometheus.NewGauge(
8686
prometheus.GaugeOpts{
@@ -103,8 +103,12 @@ func (c *metricCollector) listener(event int, ctx interface{}) {
103103
code = st.Code().String()
104104
}
105105

106-
c.callDuration.With(prometheus.Labels{"code": code}).Observe(uc.Elapsed().Seconds())
107-
c.callCounter.With(prometheus.Labels{"code": code}).Inc()
106+
method := "Unknown"
107+
if uc.Info != nil {
108+
method = uc.Info.FullMethod
109+
}
110+
c.callDuration.With(prometheus.Labels{"code": code, "method": method}).Observe(uc.Elapsed().Seconds())
111+
c.callCounter.With(prometheus.Labels{"code": code, "method": method}).Inc()
108112
}
109113
}
110114

0 commit comments

Comments
 (0)