Skip to content

Commit

Permalink
Added pprof config (#644)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Byrgazov <[email protected]>
Co-authored-by: Vladislav Byrgazov <[email protected]>
  • Loading branch information
Ex4amp1e and Vladislav Byrgazov authored Aug 15, 2024
1 parent f44dfec commit 23d668a
Show file tree
Hide file tree
Showing 4 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 @@ -46,6 +46,8 @@ This README will provide directions for building, testing, and debugging that co
* `NSM_LOG_LEVEL` - Log level
* `NSM_METRICS_EXPORT_INTERVAL` - interval between mertics exports
* `NSM_OPEN_TELEMETRY_ENDPOINT` - OpenTelemetry Collector Endpoint
* `NSM_PPROF_ENABLED` - is pprof enabled (default: "false")
* `NSM_PPROF_LISTEN_ON` - pprof URL to ListenAndServe (default: "localhost:6060")

# Build

Expand Down
5 changes: 4 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Copyright (c) 2021-2022 Nordix and/or 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 @@ -55,6 +55,9 @@ type Config struct {
LivenessCheckEnabled bool `default:"true" desc:"Dataplane liveness check enabled/disabled" split_words:"true"`
LivenessCheckInterval time.Duration `default:"200ms" 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"`
}

// 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: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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 Expand Up @@ -131,6 +132,13 @@ func main() {
}()
}

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

// ********************************************************************************
// Get a x509Source
// ********************************************************************************
Expand Down

0 comments on commit 23d668a

Please sign in to comment.