Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration for turning profiling on/off #353

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 300
Statements: 125
Lines: 320
Statements: 130
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 @@ -38,6 +38,8 @@ docker build .
* `NSM_PREFIX_SERVER_URL` - URL to VL3 IPAM server(s) (default: "vl3-ipam:5006")
* `NSM_DNS_TEMPLATES` - Represents domain naming templates in go-template format. It is using for generating the domain name for each nse/nsc in the vl3 network (default: "{{ index .Labels "podName" }}.{{ .NetworkService }}.")
* `NSM_LOG_LEVEL` - Log level (default: "INFO")
* `NSM_PPROF_ENABLED` - is pprof enabled (default: "false")
* `NSM_PPROF_LISTEN_ON` - pprof URL to ListenAndServe (default: "localhost:6060")

# Testing

Expand Down
72 changes: 72 additions & 0 deletions internal/imports/imports_linux.go

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

10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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/pprofutils"
"github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"
)

Expand All @@ -117,6 +118,8 @@ type Config struct {
PrefixServerURL []url.URL `default:"vl3-ipam:5006" desc:"URL to VL3 IPAM server(s)" split_words:"true"`
DNSTemplates []string `default:"{{ index .Labels \"podName\" }}.{{ .NetworkService }}." desc:"Represents domain naming templates in go-template format. It is using for generating the domain name for each nse/nsc in the vl3 network" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" 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"`
dnsServerAddr net.IP
dnsServerAddrCh chan net.IP
dnsConfigs genericsync.Map[string, []*networkservice.DNSConfig]
Expand Down Expand Up @@ -243,6 +246,13 @@ func main() {
}()
}

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

log.FromContext(ctx).Infof("Config: %#v", config)

// ********************************************************************************
Expand Down
Loading