Skip to content

Commit

Permalink
Added pprof config
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Byrgazov <vladislav.byrgazov@xored.com>
  • Loading branch information
Vladislav Byrgazov committed Aug 15, 2024
1 parent 234a82f commit caa1e07
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ docker build .
* `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_RULES_CONFIG_PATH` - Path to a configmap with iptables rules
* `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/pkg/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
_ "github.com/networkservicemesh/sdk/pkg/tools/log"
_ "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger"
_ "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
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2022-2023 Xored Software Inc and others.
//
// Copyright (c) 2023 Cisco Software Inc and others.
// Copyright (c) 2023-2024 Cisco Software Inc and others.
//
// Copyright (c) 2024 Nordix Foundation.
//
Expand Down Expand Up @@ -37,6 +37,7 @@ import (
nested "github.com/antonfisher/nested-logrus-formatter"
"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/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig"
Expand Down Expand Up @@ -92,6 +93,8 @@ type Config struct {
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"`
RulesConfigPath string `default:"" desc:"Path to a configmap with iptables rules" 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"`
}

// Process prints and processes env to config
Expand Down Expand Up @@ -186,6 +189,13 @@ func main() {
}()
}

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

// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 2: retrieving svid, check spire agent logs if this is the last line you see")
// ********************************************************************************
Expand Down

0 comments on commit caa1e07

Please sign in to comment.