diff --git a/README.md b/README.md index 092ea50..f49488d 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,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_LISTEN_ON` - pprof URL to ListenAndServe (default: "localhost:6060") # Testing diff --git a/main.go b/main.go index 95a0e43..f3eab9b 100644 --- a/main.go +++ b/main.go @@ -58,6 +58,7 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger" monitorauthorize "github.com/networkservicemesh/sdk/pkg/tools/monitorconnection/authorize" "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" @@ -99,6 +100,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"` + PprofListenOn string `default:"localhost:6060" desc:"pprof URL to ListenAndServe" split_words:"true"` } // supervisor starting ovsdb-server and ovs-vswitchd, @@ -157,6 +160,13 @@ func main() { }() } + // ******************************************************************************** + // Configure pprof + // ******************************************************************************** + if config.PprofEnabled { + go pprofutils.ListenAndServe(ctx, config.PprofListenOn) + } + // ******************************************************************************** log.FromContext(ctx).Infof("executing phase 2: ensure ovs is running (time since start: %s)", time.Since(starttime)) // ********************************************************************************