Skip to content

Commit

Permalink
Added pprof config
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Byrgazov <[email protected]>
  • Loading branch information
Vladislav Byrgazov committed Aug 15, 2024
1 parent eaeb6fd commit 22e96d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ docker build .
* `NSM_LIVENESS_CHECK_ENABLED` - Dataplane liveness check enabled/disabled (default: "true")
* `NSM_LIVENESS_CHECK_INTERVAL` - Dataplane liveness check interval (default: "1200ms")
* `NSM_LIVENESS_CHECK_TIMEOUT` - Dataplane liveness check timeout (default: "1s")
* `NSM_PPROF_ENABLED` - is pprof enabled (default: "false")
* `NSM_PPROF_LISTEN_ON` - pprof URL to ListenAndServe (default: "localhost:6060")

# Testing

Expand Down
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
_ "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger"
_ "github.com/networkservicemesh/sdk/pkg/tools/nsurl"
_ "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
_ "github.com/networkservicemesh/sdk/pkg/tools/pprofutils"
_ "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"
_ "github.com/networkservicemesh/sdk/pkg/tools/token"
_ "github.com/networkservicemesh/sdk/pkg/tools/tracing"
Expand Down
13 changes: 12 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2021-2022 Doc.ai its affiliates.
//
// Copyright (c) 2023 Cisco and/or its affiliates.
// Copyright (c) 2023-2024 Cisco and/or its affiliates.
//
// Copyright (c) 2024 OpenInfra Foundation Europe. All rights reserved.
//
Expand Down Expand Up @@ -37,6 +37,7 @@ import (
"github.com/edwarnicke/debug"
"github.com/edwarnicke/grpcfd"
"github.com/kelseyhightower/envconfig"
"github.com/networkservicemesh/sdk/pkg/tools/pprofutils"

Check failure on line 40 in main.go

View workflow job for this annotation

GitHub Actions / golangci-lint / golangci-lint

File is not `goimports`-ed with -local github.com/networkservicemesh (goimports)
"github.com/sirupsen/logrus"
"github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig"
"github.com/spiffe/go-spiffe/v2/workloadapi"
Expand Down Expand Up @@ -84,6 +85,9 @@ type Config struct {
LivenessCheckEnabled bool `default:"true" desc:"Dataplane liveness check enabled/disabled" split_words:"true"`
LivenessCheckInterval time.Duration `default:"1200ms" desc:"Dataplane liveness check interval" split_words:"true"`
LivenessCheckTimeout time.Duration `default:"1s" desc:"Dataplane liveness check timeout" split_words:"true"`

PprofEnabled bool `default:"false" desc:"is pprof enabled" split_words:"true"`
PprofListenOn string `default:"localhost:6060" desc:"pprof URL to ListenAndServe" split_words:"true"`
}

func main() {

Check failure on line 93 in main.go

View workflow job for this annotation

GitHub Actions / golangci-lint / golangci-lint

Function 'main' is too long (236 > 230) (funlen)
Expand Down Expand Up @@ -153,6 +157,13 @@ func main() {
}()
}

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

// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 2: run vpp and get a connection to it (time since start: %s)", time.Since(starttime))
// ********************************************************************************
Expand Down

0 comments on commit 22e96d6

Please sign in to comment.