-
-
Notifications
You must be signed in to change notification settings - Fork 980
[signal, management] Allow pprof port configuration through NB_PPROF_ADDR #4971
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request refactors pprof profiling support from hardcoded runtime initialization to an optional, configurable mechanism. Pprof integration is removed from main entry points and relocated to separate build-tagged files that read Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
management/cmd/pprof.go (1)
29-29: Remove trailing\nfrom log format string.Logrus automatically appends a newline; the explicit
\nis unnecessary.🔎 Apply this diff:
- log.Infof("listening pprof on: %s\n", listenAddr) + log.Infof("listening pprof on: %s", listenAddr)signal/cmd/pprof.go (2)
29-29: Remove trailing\nfrom log format string.Logrus automatically appends a newline; the explicit
\nis unnecessary.🔎 Apply this diff:
- log.Infof("listening pprof on: %s\n", listenAddr) + log.Infof("listening pprof on: %s", listenAddr)
1-33: Note: Intentional code duplication between signal and management pprof implementations.This file is structurally identical to
management/cmd/pprof.go. While this duplication is intentional (each package maintains its own pprof integration), consider whether a shared helper in a common package would reduce maintenance burden if the pprof pattern needs to evolve in the future.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
management/cmd/pprof.go(1 hunks)management/main.go(0 hunks)signal/cmd/pprof.go(1 hunks)signal/cmd/run.go(1 hunks)
💤 Files with no reviewable changes (1)
- management/main.go
🔇 Additional comments (4)
signal/cmd/run.go (1)
11-11: LGTM - Clean removal of hardcoded pprof integration.The removal of the
net/http/pprofimport and associated pprof startup logic is correct. Pprof functionality is now properly isolated in the build-taggedsignal/cmd/pprof.gofile.management/cmd/pprof.go (2)
1-2: LGTM - Correct build tag syntax.Using both the modern
//go:builddirective and legacy// +buildensures compatibility across Go versions.
14-17: Consider error handling for pprof server startup in goroutine frominit().The current pattern of using
log.Fatalfin a goroutine started frominit()is problematic: log.Fatalf is semantically equivalent to a non-recoverable panic without a stack-trace that prevents any deferred functions from running. This means:
- If the pprof server fails to bind (e.g., port already in use), the goroutine crashes the entire application after main has started, without allowing cleanup
- Multiple servers built with
-tags pprofon the same host without configuringNB_PPROF_ADDRcreates a port conflict scenarioUse
log.Errorfinstead, allowing graceful degradation, or implement synchronous port availability validation during startup with proper error signaling.signal/cmd/pprof.go (1)
1-2: LGTM - Correct build tag syntax.Using both the modern
//go:builddirective and legacy// +buildensures compatibility across Go versions.



Describe your changes
Signal and Management servers previously hard‑coded a pprof listener on
localhost:6060, which caused port conflicts when multiple services ran in the same namespace (ie; in the same pod or as a NixOS service). This PR refactors both to use the samepprof.gohelper pattern already present in Client/Relay.Does this change build semantics though? To test it, I ran it with
-tags pprof. If it does, it shouldn't be a huge change to just slap whatpprof.godoes directly into the relevant functions.Issue ticket number and link
Fixes #4923
Stack
Branch:
pprof-configurable-signal-mgmtChecklist
Documentation
Select exactly one:
The behavior is consistent with existing Client/Relay profiling logic, so no new user‑facing configuration is introduced beyond the existing NB_PPROF_ADDR.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.