mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-21 00:33:10 +00:00
[FIX] make pprof labels conformant with prometheus spec
This commit is contained in:
parent
ec459b23c8
commit
c8f515dff7
5 changed files with 11 additions and 11 deletions
|
@ -136,7 +136,7 @@ func (g *Manager) doShutdown() {
|
||||||
}
|
}
|
||||||
g.lock.Lock()
|
g.lock.Lock()
|
||||||
g.shutdownCtxCancel()
|
g.shutdownCtxCancel()
|
||||||
atShutdownCtx := pprof.WithLabels(g.hammerCtx, pprof.Labels("graceful-lifecycle", "post-shutdown"))
|
atShutdownCtx := pprof.WithLabels(g.hammerCtx, pprof.Labels("gracefulLifecycle", "post-shutdown"))
|
||||||
pprof.SetGoroutineLabels(atShutdownCtx)
|
pprof.SetGoroutineLabels(atShutdownCtx)
|
||||||
for _, fn := range g.toRunAtShutdown {
|
for _, fn := range g.toRunAtShutdown {
|
||||||
go fn()
|
go fn()
|
||||||
|
@ -167,7 +167,7 @@ func (g *Manager) doHammerTime(d time.Duration) {
|
||||||
default:
|
default:
|
||||||
log.Warn("Setting Hammer condition")
|
log.Warn("Setting Hammer condition")
|
||||||
g.hammerCtxCancel()
|
g.hammerCtxCancel()
|
||||||
atHammerCtx := pprof.WithLabels(g.terminateCtx, pprof.Labels("graceful-lifecycle", "post-hammer"))
|
atHammerCtx := pprof.WithLabels(g.terminateCtx, pprof.Labels("gracefulLifecycle", "post-hammer"))
|
||||||
pprof.SetGoroutineLabels(atHammerCtx)
|
pprof.SetGoroutineLabels(atHammerCtx)
|
||||||
}
|
}
|
||||||
g.lock.Unlock()
|
g.lock.Unlock()
|
||||||
|
@ -183,7 +183,7 @@ func (g *Manager) doTerminate() {
|
||||||
default:
|
default:
|
||||||
log.Warn("Terminating")
|
log.Warn("Terminating")
|
||||||
g.terminateCtxCancel()
|
g.terminateCtxCancel()
|
||||||
atTerminateCtx := pprof.WithLabels(g.managerCtx, pprof.Labels("graceful-lifecycle", "post-terminate"))
|
atTerminateCtx := pprof.WithLabels(g.managerCtx, pprof.Labels("gracefulLifecycle", "post-terminate"))
|
||||||
pprof.SetGoroutineLabels(atTerminateCtx)
|
pprof.SetGoroutineLabels(atTerminateCtx)
|
||||||
|
|
||||||
for _, fn := range g.toRunAtTerminate {
|
for _, fn := range g.toRunAtTerminate {
|
||||||
|
|
|
@ -65,10 +65,10 @@ func (g *Manager) prepare(ctx context.Context) {
|
||||||
g.hammerCtx, g.hammerCtxCancel = context.WithCancel(ctx)
|
g.hammerCtx, g.hammerCtxCancel = context.WithCancel(ctx)
|
||||||
g.managerCtx, g.managerCtxCancel = context.WithCancel(ctx)
|
g.managerCtx, g.managerCtxCancel = context.WithCancel(ctx)
|
||||||
|
|
||||||
g.terminateCtx = pprof.WithLabels(g.terminateCtx, pprof.Labels("graceful-lifecycle", "with-terminate"))
|
g.terminateCtx = pprof.WithLabels(g.terminateCtx, pprof.Labels("gracefulLifecycle", "with-terminate"))
|
||||||
g.shutdownCtx = pprof.WithLabels(g.shutdownCtx, pprof.Labels("graceful-lifecycle", "with-shutdown"))
|
g.shutdownCtx = pprof.WithLabels(g.shutdownCtx, pprof.Labels("gracefulLifecycle", "with-shutdown"))
|
||||||
g.hammerCtx = pprof.WithLabels(g.hammerCtx, pprof.Labels("graceful-lifecycle", "with-hammer"))
|
g.hammerCtx = pprof.WithLabels(g.hammerCtx, pprof.Labels("gracefulLifecycle", "with-hammer"))
|
||||||
g.managerCtx = pprof.WithLabels(g.managerCtx, pprof.Labels("graceful-lifecycle", "with-manager"))
|
g.managerCtx = pprof.WithLabels(g.managerCtx, pprof.Labels("gracefulLifecycle", "with-manager"))
|
||||||
|
|
||||||
if !g.setStateTransition(stateInit, stateRunning) {
|
if !g.setStateTransition(stateInit, stateRunning) {
|
||||||
panic("invalid graceful manager state: transition from init to running failed")
|
panic("invalid graceful manager state: transition from init to running failed")
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (g *Manager) notify(msg systemdNotifyMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Manager) start() {
|
func (g *Manager) start() {
|
||||||
// Now label this and all goroutines created by this goroutine with the graceful-lifecycle manager
|
// Now label this and all goroutines created by this goroutine with the gracefulLifecycle manager
|
||||||
pprof.SetGoroutineLabels(g.managerCtx)
|
pprof.SetGoroutineLabels(g.managerCtx)
|
||||||
defer pprof.SetGoroutineLabels(g.ctx)
|
defer pprof.SetGoroutineLabels(g.ctx)
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *Manager) start() {
|
func (g *Manager) start() {
|
||||||
// Now label this and all goroutines created by this goroutine with the graceful-lifecycle manager
|
// Now label this and all goroutines created by this goroutine with the gracefulLifecycle manager
|
||||||
pprof.SetGoroutineLabels(g.managerCtx)
|
pprof.SetGoroutineLabels(g.managerCtx)
|
||||||
defer pprof.SetGoroutineLabels(g.ctx)
|
defer pprof.SetGoroutineLabels(g.ctx)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// DescriptionPProfLabel is a label set on goroutines that have a process attached
|
// DescriptionPProfLabel is a label set on goroutines that have a process attached
|
||||||
const DescriptionPProfLabel = "process-description"
|
const DescriptionPProfLabel = "processDescription"
|
||||||
|
|
||||||
// PIDPProfLabel is a label set on goroutines that have a process attached
|
// PIDPProfLabel is a label set on goroutines that have a process attached
|
||||||
const PIDPProfLabel = "pid"
|
const PIDPProfLabel = "pid"
|
||||||
|
@ -35,7 +35,7 @@ const PIDPProfLabel = "pid"
|
||||||
const PPIDPProfLabel = "ppid"
|
const PPIDPProfLabel = "ppid"
|
||||||
|
|
||||||
// ProcessTypePProfLabel is a label set on goroutines that have a process attached
|
// ProcessTypePProfLabel is a label set on goroutines that have a process attached
|
||||||
const ProcessTypePProfLabel = "process-type"
|
const ProcessTypePProfLabel = "processType"
|
||||||
|
|
||||||
// IDType is a pid type
|
// IDType is a pid type
|
||||||
type IDType string
|
type IDType string
|
||||||
|
|
Loading…
Reference in a new issue