diff --git a/.changelog/19721.txt b/.changelog/19721.txt new file mode 100644 index 0000000000..5a6b4bbd37 --- /dev/null +++ b/.changelog/19721.txt @@ -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 +``` diff --git a/agent/consul/client.go b/agent/consul/client.go index fa5f1239e1..5216ffe2d5 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -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