Skip to content

Commit

Permalink
add rpc method request gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
unclezoro committed Jan 10, 2021
1 parent 894b1e3 commit 5bd7332
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions rpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func (h *handler) handleCall(cp *callProc, msg *jsonrpcMessage) *jsonrpcMessage
successfulRequestGauge.Inc(1)
}
rpcServingTimer.UpdateSince(start)
newRPCRequestGauge(msg.Method).Inc(1)
newRPCServingTimer(msg.Method, answer.Error == nil).UpdateSince(start)
}
return answer
Expand Down
5 changes: 5 additions & 0 deletions rpc/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ func newRPCServingTimer(method string, valid bool) metrics.Timer {
m := fmt.Sprintf("rpc/duration/%s/%s", method, flag)
return metrics.GetOrRegisterTimer(m, nil)
}

func newRPCRequestGauge(method string) metrics.Gauge {
m := fmt.Sprintf("rpc/count/%s", method)
return metrics.GetOrRegisterGauge(m, nil)
}

0 comments on commit 5bd7332

Please sign in to comment.