Skip to content

Commit

Permalink
Merge pull request #466 from Ex4amp1e/add-pprof-enable-conf
Browse files Browse the repository at this point in the history
Add configuration for turning profiling on/off
  • Loading branch information
denis-tingaikin authored Aug 9, 2024
2 parents eaa1647 + e4905b3 commit acc9394
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ linters-settings:
dupl:
threshold: 150
funlen:
lines: 120
statements: 60
lines: 140
statements: 70
goconst:
min-len: 2
min-occurrences: 2
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ docker build .
* `NSM_LOG_LEVEL` - Log level (default: "INFO")
* `NSM_OPEN_TELEMETRY_ENDPOINT` - OpenTelemetry Collector Endpoint (default: "otel-collector.observability.svc.cluster.local:4317")
* `NSM_METRICS_EXPORT_INTERVAL` - interval between mertics exports (default: "10s")
* `NSM_PPROF_ENABLED` - is pprof enabled (default: "false")
* `NSM_PPROF_PORT` - pprof port (default: "6060")
* `NSM_KUBELET_QPS` - kubelet config settings (default: "205")

# Testing
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/tools/grpcutils"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger"
"github.com/networkservicemesh/sdk/pkg/tools/pprof"
)

// Config is configuration for cmd-registry-memory
Expand All @@ -64,6 +65,8 @@ type Config struct {
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
OpenTelemetryEndpoint string `default:"otel-collector.observability.svc.cluster.local:4317" desc:"OpenTelemetry Collector Endpoint" split_words:"true"`
MetricsExportInterval time.Duration `default:"10s" desc:"interval between mertics exports" split_words:"true"`
PprofEnabled bool `default:"false" desc:"is pprof enabled" split_words:"true"`
PprofPort uint16 `default:"6060" desc:"pprof port" split_words:"true"`
// The QPS value is calculated for 40 NSEs, 40 NSCs and 5 FWDs.
// NSC, FWD and NSE refreshes occur every second
// NSE Refreshes: 1 refresh per sec. * 40 nses
Expand Down Expand Up @@ -126,6 +129,11 @@ func main() {
}()
}

// Configure pprof
if config.PprofEnabled {
go pprof.Init(ctx, config.PprofPort)
}

// Get a X509Source
source, err := workloadapi.NewX509Source(ctx)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/internal/imports/imports_linux.go

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

0 comments on commit acc9394

Please sign in to comment.