Skip to content

Commit e763555

Browse files
addressed code review comments.
1 parent b0e7fd4 commit e763555

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

region/client.go

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,7 @@ func (c *client) trySend(rpc hrpc.Call) (err error) {
436436
c.fail(err)
437437
}
438438
if r := c.unregisterRPC(id); r != nil {
439-
if m, ok := r.(*multi); ok {
440-
for _, call := range m.calls {
441-
if call != nil {
442-
rpcResultCount.WithLabelValues(c.Addr(), call.Name(), "failure").Inc()
443-
}
444-
}
445-
} else {
446-
rpcResultCount.WithLabelValues(c.Addr(), r.Name(), "failure").Inc()
447-
}
439+
c.trackRPCResult(r, "error")
448440
// we are the ones to unregister the rpc,
449441
// return err to notify client of it
450442
return err
@@ -473,6 +465,20 @@ func (c *client) receiveRPCs() {
473465
}
474466
}
475467

468+
func (c *client) trackRPCResult(rpc hrpc.Call, status string) {
469+
if m, ok := rpc.(*multi); ok {
470+
for _, call := range m.calls {
471+
if call != nil {
472+
rpcResultCount.WithLabelValues(
473+
c.Addr(), call.Name(), status, "batch").Inc()
474+
}
475+
}
476+
} else {
477+
rpcResultCount.WithLabelValues(
478+
c.Addr(), rpc.Name(), status, "unary").Inc()
479+
}
480+
}
481+
476482
func (c *client) receive(r io.Reader) (err error) {
477483
var (
478484
sz [4]byte
@@ -527,19 +533,11 @@ func (c *client) receive(r io.Reader) (err error) {
527533
// It's our responsibility to deliver the response or error to the
528534
// caller as we unregistered the rpc.
529535
defer func() {
530-
status := "success"
536+
status := "ok"
531537
if err != nil {
532-
status = "failure"
533-
}
534-
if m, ok := rpc.(*multi); ok {
535-
for _, call := range m.calls {
536-
if call != nil {
537-
rpcResultCount.WithLabelValues(c.Addr(), call.Name(), status).Inc()
538-
}
539-
}
540-
} else {
541-
rpcResultCount.WithLabelValues(c.Addr(), rpc.Name(), status).Inc()
538+
status = "error"
542539
}
540+
c.trackRPCResult(rpc, status)
543541
returnResult(rpc, response, err)
544542
}()
545543

region/prometheus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ var (
4848
Name: "rpc_result_count",
4949
Help: "Number of RPC operations by result status and operation type",
5050
},
51-
[]string{"regionserver", "operation", "status"},
51+
[]string{"regionserver", "operation", "status", "type"},
5252
)
5353
)

0 commit comments

Comments
 (0)