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 configuration for turning profiling on/off #81

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 Cisco and/or its affiliates.
// Copyright (c) 2023-2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down 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.

8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 Cisco and/or its affiliates.
// Copyright (c) 2023-2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down 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
Loading