Skip to content

Commit

Permalink
improve client RPC metrics consistency (#19721)
Browse files Browse the repository at this point in the history
The client.rpc metric now excludes internal retries for consistency
with client.rpc.exceeded and client.rpc.failed. All of these metrics
now increment at most once per RPC method call, allowing for
accurate calculation of failure / rate limit application occurrence.

Additionally, if an RPC fails because no servers are present,
client.rpc.failed is now incremented.
  • Loading branch information
jkirschner-hashicorp authored Dec 6, 2023
1 parent efe279f commit d3e658b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changelog/19721.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:improvement
metrics: modify consul.client.rpc metric to exclude internal retries for consistency with consul.client.rpc.exceeded and consul.client.rpc.failed
```
```release-note:improvement
metrics: increment consul.client.rpc.failed if RPC fails because no servers are accessible
```
4 changes: 3 additions & 1 deletion agent/consul/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,17 @@ func (c *Client) RPC(ctx context.Context, method string, args interface{}, reply
firstCheck := time.Now()
retryCount := 0
previousJitter := time.Duration(0)

metrics.IncrCounter([]string{"client", "rpc"}, 1)
TRY:
retryCount++
manager, server := c.router.FindLANRoute()
if server == nil {
metrics.IncrCounter([]string{"client", "rpc", "failed"}, 1)
return structs.ErrNoServers
}

// Enforce the RPC limit.
metrics.IncrCounter([]string{"client", "rpc"}, 1)
if !c.rpcLimiter.Load().(*rate.Limiter).Allow() {
metrics.IncrCounter([]string{"client", "rpc", "exceeded"}, 1)
return structs.ErrRPCRateExceeded
Expand Down

0 comments on commit d3e658b

Please sign in to comment.