Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
79d020c
Add design spec for conditional init() execution in busybox binary
janisz Apr 13, 2026
ce0bf8d
Add implementation plan for conditional init() execution
janisz Apr 13, 2026
99f16b5
feat: create central/app package structure
janisz Apr 13, 2026
391316f
docs: analyze sensor → central import chains
janisz Apr 13, 2026
6834046
feat: establish app/ structure for config-controller
janisz Apr 13, 2026
29b615f
fix: move admission-control init() to explicit initialization
janisz Apr 13, 2026
2cf4237
refactor: add GraphQL loader init structure (stub)
janisz Apr 13, 2026
2af5b79
refactor: add compliance init structure (stub)
janisz Apr 13, 2026
eb3f1e0
refactor: move Central metrics from init() to explicit registration
janisz Apr 13, 2026
bdfdc77
refactor: move sensor metrics init() to explicit initialization
janisz Apr 13, 2026
2287e20
docs: add verification report and architecture guide
janisz Apr 13, 2026
0449ea6
docs: Phase 5 low-hanging fruit analysis and migration plan
janisz Apr 13, 2026
8b5a49f
docs: add busybox-scoped Phase 5 recommendations
janisz Apr 13, 2026
eca4ef0
docs: add heap profile component labeling fix
janisz Apr 13, 2026
d3de83e
feat: add component labeling for heap/CPU profiles
janisz Apr 13, 2026
987c76a
docs: update heap profile labeling doc with implementation details
janisz Apr 13, 2026
82a6968
refactor: minimize metrics init diff by keeping logic in metrics pack…
janisz Apr 13, 2026
c78f077
chore: remove documentation files
janisz Apr 13, 2026
93f7842
refactor: remove app/init.go files, call metrics.Init directly from a…
janisz Apr 13, 2026
db6b9d5
fix: update metric Init() comments to reference app.go
janisz Apr 13, 2026
f1a6ada
refactor: migrate GraphQL loaders and compliance checks to explicit I…
janisz Apr 13, 2026
6744213
refactor: rename init() to register*() in kubernetes compliance checks
janisz Apr 13, 2026
9b30c56
refactor: rename init() to Register*() in hipaa_164 compliance checks
janisz Apr 13, 2026
f24eb46
refactor: rename init() to Register*() in nist80053 compliance checks
janisz Apr 13, 2026
668c7ef
refactor: rename init() to Register*() in nist800-190 compliance checks
janisz Apr 13, 2026
0a704c0
refactor: rename init() to Register*() in pcidss32 compliance checks
janisz Apr 13, 2026
b84cb73
refactor: replace blank imports with explicit Init() calls in complia…
janisz Apr 13, 2026
3b1086c
refactor: rename init() to Register*() in central hipaa_164 complianc…
janisz Apr 13, 2026
530b499
refactor: rename init() to Register*() in central nist800-190 complia…
janisz Apr 13, 2026
f487fd3
refactor: rename init() to Register*() in central nist80053 complianc…
janisz Apr 13, 2026
4e8afdd
refactor: rename init() to Register*() in central pcidss32 compliance…
janisz Apr 13, 2026
f8083d4
refactor: rename init() to Init() in central remote compliance checks
janisz Apr 13, 2026
4c0dbf7
refactor: replace blank imports with explicit Init() in central compl…
janisz Apr 13, 2026
998006c
refactor: rename init() to Register*() in all notifier factories
janisz Apr 13, 2026
3ab5d12
refactor: rename init() to Register*() in compliance standards metadata
janisz Apr 13, 2026
5dfcdc9
refactor: rename init() to Register*() in external backup plugins
janisz Apr 13, 2026
26ed417
refactor: migrate init() to explicit Init() pattern and centralize pr…
janisz Apr 14, 2026
e9f029f
fix: break import cycle in sensor telemetry gatherers
janisz Apr 14, 2026
4eb3d12
fix: resolve golangci-lint failures from init() migration
janisz Apr 14, 2026
51425e9
fix: expand gochecknoinits exclusion to cover all legacy directories
janisz Apr 14, 2026
441a472
refactor: migrate init() to explicit Init() pattern across all compon…
janisz Apr 14, 2026
d62a670
refactor: migrate init() to explicit Init() in roxctl, sensor, tools,…
janisz Apr 14, 2026
a7c0386
style: fix gofmt formatting in volume converter files
janisz Apr 14, 2026
0d397c9
config: add pkg/images/enricher/metadata.go to gochecknoinits exclusion
janisz Apr 14, 2026
0cb5d2a
refactor: migrate migrator init() to explicit Register() pattern
janisz Apr 14, 2026
6fceb99
refactor: migrate remaining 9 pkg/ init() functions to explicit Init()
janisz Apr 14, 2026
dd31084
refactor: unexport centralRun - only used within main package
janisz Apr 14, 2026
aeee0e4
fix: apply critical fixes from split PRs to main branch
janisz Apr 15, 2026
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
Prev Previous commit
Next Next commit
feat: add component labeling for heap/CPU profiles
Add pprof goroutine labels to all busybox components so heap and CPU
profiles correctly identify which component they're from.

Problem: After busybox consolidation (PR #19819), all components report
"File: central" in profiles instead of actual component name (e.g.,
"kubernetes-sensor", "admission-control").

Root cause: Single binary, Go profiler reports binary name not symlink.

Solution: Call profiling.SetComponentLabel() early in each component's
app.Run() to tag goroutines with component name from os.Args[0].

Components updated:
- central
- sensor/kubernetes
- sensor/admission-control
- config-controller
- migrator
- compliance
- roxagent
- sensor-upgrader
- roxctl

This enables filtering profiles by component:
  go tool pprof -tags component=kubernetes-sensor http://pod:6060/debug/pprof/heap

User request: "Can we fix following finding (not only for sensor but for
all other components use their args[0] instead of central)"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
  • Loading branch information
janisz and claude committed Apr 13, 2026
commit d3de83e0792a1701684149f2b3281c6d3d8e89fc
7 changes: 4 additions & 3 deletions central/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ import (
"github.com/stackrox/rox/pkg/logging"
"github.com/stackrox/rox/pkg/memlimit"
"github.com/stackrox/rox/pkg/premain"
"github.com/stackrox/rox/pkg/profiling"
)

var (
log = logging.LoggerForModule()
)

// Run is the main entry point for the central application.
// For Phase 1, this just does early initialization.
// The actual central logic remains in main.CentralRun() until full migration.
// Performs early initialization and component-specific setup before
// main.CentralRun() starts the actual central service logic.
func Run() {
profiling.SetComponentLabel()
memlimit.SetMemoryLimit()
premain.StartMain()

// Component-specific initialization will be added in Phase 3
initMetrics()
initCompliance()
initGraphQL()
Expand Down
2 changes: 2 additions & 0 deletions compliance/cmd/compliance/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/stackrox/rox/pkg/env"
"github.com/stackrox/rox/pkg/logging"
"github.com/stackrox/rox/pkg/memlimit"
"github.com/stackrox/rox/pkg/profiling"
"github.com/stackrox/rox/pkg/retry/handler"
)

Expand All @@ -20,6 +21,7 @@ var (

// Run is the main entry point for the compliance application.
func Run() {
profiling.SetComponentLabel()
memlimit.SetMemoryLimit()

if err := continuousprofiling.SetupClient(continuousprofiling.DefaultConfig()); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions compliance/virtualmachines/roxagent/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import (

"github.com/stackrox/rox/compliance/virtualmachines/roxagent/cmd"
"github.com/stackrox/rox/pkg/logging"
"github.com/stackrox/rox/pkg/profiling"
)

var log = logging.LoggerForModule()

// Run is the main entry point for the roxagent application.
func Run() {
profiling.SetComponentLabel()
// Create a context that is cancellable on the usual command line signals. Double
// signal forcefully exits.
ctx, cancel := context.WithCancel(context.Background())
Expand Down
2 changes: 2 additions & 0 deletions config-controller/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/stackrox/rox/config-controller/pkg/client"
"github.com/stackrox/rox/pkg/env"
"github.com/stackrox/rox/pkg/logging"
"github.com/stackrox/rox/pkg/profiling"
"github.com/stackrox/rox/pkg/tlsprofile"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand Down Expand Up @@ -62,6 +63,7 @@ func init() {

// Run is the main entry point for the config-controller application.
func Run() {
profiling.SetComponentLabel()
var metricsAddr string
var probeAddr string
var secureMetrics bool
Expand Down
2 changes: 2 additions & 0 deletions migrator/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import (
"github.com/stackrox/rox/pkg/postgres"
"github.com/stackrox/rox/pkg/postgres/pgadmin"
"github.com/stackrox/rox/pkg/postgres/pgconfig"
"github.com/stackrox/rox/pkg/profiling"
"github.com/stackrox/rox/pkg/retry"
"github.com/stackrox/rox/pkg/version"
)

// Run is the main entry point for the migrator application.
func Run() {
profiling.SetComponentLabel()
startProfilingServer()
if err := run(); err != nil {
log.WriteToStderrf("Migrator failed: %+v", err)
Expand Down
20 changes: 20 additions & 0 deletions pkg/profiling/component.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package profiling

import (
"context"
"os"
"path/filepath"
"runtime/pprof"
)

// SetComponentLabel tags the current goroutine with the component name
// derived from os.Args[0]. This ensures heap and CPU profiles correctly
// identify which component they're from in busybox-style binaries.
//
// Call this early in app initialization, before starting goroutines.
func SetComponentLabel() {
componentName := filepath.Base(os.Args[0])
labels := pprof.Labels("component", componentName)
ctx := pprof.WithLabels(context.Background(), labels)
pprof.SetGoroutineLabels(ctx)
}
2 changes: 2 additions & 0 deletions roxctl/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/spf13/cobra"
"github.com/stackrox/rox/pkg/clientconn"
"github.com/stackrox/rox/pkg/profiling"
"github.com/stackrox/rox/pkg/sync"
"github.com/stackrox/rox/roxctl/common"
"github.com/stackrox/rox/roxctl/maincommand"
Expand All @@ -17,6 +18,7 @@ import (

// Run is the main entry point for the roxctl application.
func Run() {
profiling.SetComponentLabel()
c := maincommand.Command()

c.SetHelpFunc(utils.FormatHelp)
Expand Down
2 changes: 2 additions & 0 deletions sensor/admission-control/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/stackrox/rox/pkg/mtls"
"github.com/stackrox/rox/pkg/mtls/verifier"
"github.com/stackrox/rox/pkg/pods"
"github.com/stackrox/rox/pkg/profiling"
"github.com/stackrox/rox/pkg/safe"
"github.com/stackrox/rox/pkg/utils"
"github.com/stackrox/rox/pkg/version"
Expand All @@ -41,6 +42,7 @@ var (

// Run is the main entry point for the admission-control application.
func Run() {
profiling.SetComponentLabel()
memlimit.SetMemoryLimit()
initMetrics()

Expand Down
2 changes: 2 additions & 0 deletions sensor/kubernetes/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/stackrox/rox/pkg/memlimit"
"github.com/stackrox/rox/pkg/metrics"
"github.com/stackrox/rox/pkg/premain"
"github.com/stackrox/rox/pkg/profiling"
"github.com/stackrox/rox/pkg/utils"
"github.com/stackrox/rox/pkg/version"
"github.com/stackrox/rox/sensor/common/centralclient"
Expand All @@ -35,6 +36,7 @@ var log = logging.LoggerForModule()

// Run is the main entry point for the kubernetes-sensor application.
func Run() {
profiling.SetComponentLabel()
memlimit.SetMemoryLimit()

premain.StartMain()
Expand Down
2 changes: 2 additions & 0 deletions sensor/upgrader/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/stackrox/rox/pkg/clientconn"
"github.com/stackrox/rox/pkg/features"
"github.com/stackrox/rox/pkg/logging"
"github.com/stackrox/rox/pkg/profiling"
"github.com/stackrox/rox/pkg/utils"
"github.com/stackrox/rox/pkg/version"
"github.com/stackrox/rox/sensor/upgrader/config"
Expand All @@ -25,6 +26,7 @@ var (

// Run is the main entry point for the sensor-upgrader application.
func Run() {
profiling.SetComponentLabel()
log.Infof("StackRox Sensor Upgrader, version %s", version.GetMainVersion())
features.LogFeatureFlags()

Expand Down