mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Add SIGUSR2 pprof to agent and proxy (#27510)
* Add SIGUSR2 pprof to agent * changelog * Update command/agent.go Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com> * Update command/agent.go Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com> * Add to proxy, update tests * Fix path * Changelog * dry * choose one error style --------- Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -74,6 +75,7 @@ type AgentCommand struct {
|
||||
|
||||
ShutdownCh chan struct{}
|
||||
SighupCh chan struct{}
|
||||
SigUSR2Ch chan struct{}
|
||||
|
||||
tlsReloadFuncsLock sync.RWMutex
|
||||
tlsReloadFuncs []reloadutil.ReloadFunc
|
||||
@@ -758,6 +760,16 @@ func (c *AgentCommand) Run(args []string) int {
|
||||
case c.reloadedCh <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
case <-c.SigUSR2Ch:
|
||||
pprofPath := filepath.Join(os.TempDir(), "vault-agent-pprof")
|
||||
cpuProfileDuration := time.Second * 1
|
||||
err := WritePprofToFile(pprofPath, cpuProfileDuration)
|
||||
if err != nil {
|
||||
c.logger.Error(err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
c.logger.Info(fmt.Sprintf("Wrote pprof files to: %s", pprofPath))
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user