@@ -22,6 +22,12 @@ const (
2222 watchdogMsg systemdNotifyMsg = "WATCHDOG=1"
2323)
2424
25+ // LifecyclePProfLabel is a label marking manager lifecycle phase
26+ // Making it compliant with prometheus key regex https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
27+ // would enable someone interested to be able to to continuously gather profiles into pyroscope.
28+ // Other labels for pprof (in "modules/process" package) should also follow this rule.
29+ const LifecyclePProfLabel = "graceful_lifecycle"
30+
2531func statusMsg (msg string ) systemdNotifyMsg {
2632 return systemdNotifyMsg ("STATUS=" + msg )
2733}
@@ -65,10 +71,10 @@ func (g *Manager) prepare(ctx context.Context) {
6571 g .hammerCtx , g .hammerCtxCancel = context .WithCancel (ctx )
6672 g .managerCtx , g .managerCtxCancel = context .WithCancel (ctx )
6773
68- g .terminateCtx = pprof .WithLabels (g .terminateCtx , pprof .Labels ("graceful-lifecycle" , "with-terminate" ))
69- g .shutdownCtx = pprof .WithLabels (g .shutdownCtx , pprof .Labels ("graceful-lifecycle" , "with-shutdown" ))
70- g .hammerCtx = pprof .WithLabels (g .hammerCtx , pprof .Labels ("graceful-lifecycle" , "with-hammer" ))
71- g .managerCtx = pprof .WithLabels (g .managerCtx , pprof .Labels ("graceful-lifecycle" , "with-manager" ))
74+ g .terminateCtx = pprof .WithLabels (g .terminateCtx , pprof .Labels (LifecyclePProfLabel , "with-terminate" ))
75+ g .shutdownCtx = pprof .WithLabels (g .shutdownCtx , pprof .Labels (LifecyclePProfLabel , "with-shutdown" ))
76+ g .hammerCtx = pprof .WithLabels (g .hammerCtx , pprof .Labels (LifecyclePProfLabel , "with-hammer" ))
77+ g .managerCtx = pprof .WithLabels (g .managerCtx , pprof .Labels (LifecyclePProfLabel , "with-manager" ))
7278
7379 if ! g .setStateTransition (stateInit , stateRunning ) {
7480 panic ("invalid graceful manager state: transition from init to running failed" )
0 commit comments