Skip to content

Commit

Permalink
Added pprof config
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Byrgazov <[email protected]>
  • Loading branch information
Vladislav Byrgazov committed Aug 15, 2024
1 parent fd9be7d commit 0b59589
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ linters-settings:
threshold: 150
funlen:
Lines: 300
Statements: 125
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

0 comments on commit 0b59589

Please sign in to comment.