Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics for requests forwarded by standbys. #11366

Merged
merged 3 commits into from Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/11366.txt
@@ -0,0 +1,3 @@
```release-note:improvement
core: Add metrics for standby node forwarding.
```
5 changes: 4 additions & 1 deletion vault/request_forwarding.go
Expand Up @@ -14,9 +14,9 @@ import (
"sync"
"time"

"github.com/armon/go-metrics"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/helper/forwarding"

"github.com/hashicorp/vault/sdk/helper/consts"
"github.com/hashicorp/vault/vault/cluster"
"github.com/hashicorp/vault/vault/replication"
Expand Down Expand Up @@ -336,6 +336,8 @@ func (c *Core) ForwardRequest(req *http.Request) (int, http.Header, []byte, erro
return 0, nil, nil, ErrCannotForward
}

defer metrics.MeasureSince([]string{"ha", "rpc", "client", "forward"}, time.Now())

origPath := req.URL.Path
defer func() {
req.URL.Path = origPath
Expand All @@ -354,6 +356,7 @@ func (c *Core) ForwardRequest(req *http.Request) (int, http.Header, []byte, erro
}
resp, err := c.rpcForwardingClient.ForwardRequest(req.Context(), freq)
if err != nil {
metrics.IncrCounter([]string{"ha", "rpc", "client", "forward", "errors"}, 1)
vishalnayak marked this conversation as resolved.
Show resolved Hide resolved
c.logger.Error("error during forwarded RPC request", "error", err)
return 0, nil, nil, fmt.Errorf("error during forwarding RPC request")
}
Expand Down