Skip to content

Commit 995c829

Browse files
feat: add logs on up and down scaling threads (#1695)
1 parent 96400a8 commit 995c829

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scaling.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ func scaleWorkerThread(worker *worker) {
9999
}
100100

101101
autoScaledThreads = append(autoScaledThreads, thread)
102+
103+
logger.LogAttrs(context.Background(), slog.LevelInfo, "upscaling worker thread", slog.String("worker", worker.name), slog.Int("thread", thread.threadIndex), slog.Int("num_threads", len(autoScaledThreads)))
102104
}
103105

104106
// scaleRegularThread adds a regular PHP thread automatically
@@ -122,6 +124,8 @@ func scaleRegularThread() {
122124
}
123125

124126
autoScaledThreads = append(autoScaledThreads, thread)
127+
128+
logger.LogAttrs(context.Background(), slog.LevelInfo, "upscaling regular thread", slog.Int("thread", thread.threadIndex), slog.Int("num_threads", len(autoScaledThreads)))
125129
}
126130

127131
func startUpscalingThreads(maxScaledThreads int, scale chan *frankenPHPContext, done chan struct{}) {
@@ -197,10 +201,10 @@ func deactivateThreads() {
197201

198202
// convert threads to inactive if they have been idle for too long
199203
if thread.state.is(stateReady) && waitTime > maxThreadIdleTime.Milliseconds() {
200-
logger.LogAttrs(context.Background(), slog.LevelDebug, "auto-converting thread to inactive", slog.Int("thread", thread.threadIndex))
201204
convertToInactiveThread(thread)
202205
stoppedThreadCount++
203206
autoScaledThreads = append(autoScaledThreads[:i], autoScaledThreads[i+1:]...)
207+
logger.LogAttrs(context.Background(), slog.LevelInfo, "downscaling thread", slog.Int("thread", thread.threadIndex), slog.Int64("wait_time", waitTime), slog.Int("num_threads", len(autoScaledThreads)))
204208

205209
continue
206210
}

0 commit comments

Comments
 (0)