Skip to content

Commit

Permalink
Added pprof config
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Byrgazov <vladislav.byrgazov@xored.com>
  • Loading branch information
Vladislav Byrgazov committed Aug 15, 2024
1 parent 9b9c169 commit 99554f4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ This driver mounts a directory containing a Network Service API socket as an eph
* `NSM_SOCKET_DIR` - Path to the NSM API socket directory
* `NSM_CSI_SOCKET_PATH` - Path to the CSI socket (default: "/nsm-csi/csi.sock")
* `NSM_VERSION` - Version (default: "undefined")
* `NSM_PPROF_ENABLED` - is pprof enabled (default: "false")
* `NSM_PPROF_LISTEN_ON` - pprof URL to ListenAndServe (default: "localhost:6060")

## How it Works

Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type Config struct {
SocketDir string `default:"" desc:"Path to the NSM API socket directory" split_words:"true"`
CSISocketPath string `default:"/nsm-csi/csi.sock" desc:"Path to the CSI socket" split_words:"true"`
Version string `default:"undefined" desc:"Version"`
PprofEnabled bool `default:"false" desc:"is pprof enabled" split_words:"true"`
PprofListenOn string `default:"localhost:6060" desc:"pprof URL to ListenAndServe" split_words:"true"`
}

// IsValid - check if configuration is valid
Expand Down
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/networkservicemesh/cmd-csi-driver/pkg/logkeys"
"github.com/networkservicemesh/cmd-csi-driver/pkg/server"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/networkservicemesh/sdk/pkg/tools/pprofutils"
)

func main() {
Expand All @@ -42,6 +43,11 @@ func main() {
logger.Fatalf("error processing rootConf from env: %+v", err)
}

// Configure pprof
if c.PprofEnabled {
go pprofutils.ListenAndServe(ctx, c.PprofListenOn)
}

logger.WithField(logkeys.Version, c.Version).
WithField(logkeys.NodeID, c.NodeName).
WithField(logkeys.NSMSocketDir, c.SocketDir).
Expand Down

0 comments on commit 99554f4

Please sign in to comment.