55 isWaitingRoomEnabled ,
66} from './config'
77import { getFireworksHealth } from './fireworks-health'
8- import { admitFromQueue , queueDepth , sweepExpired } from './store'
8+ import { activeCount , admitFromQueue , queueDepth , sweepExpired } from './store'
99
1010import type { FireworksHealth } from './fireworks-health'
1111
@@ -14,6 +14,7 @@ import { logger } from '@/util/logger'
1414export interface AdmissionDeps {
1515 sweepExpired : ( now : Date , graceMs : number ) => Promise < number >
1616 queueDepth : ( ) => Promise < number >
17+ activeCount : ( ) => Promise < number >
1718 admitFromQueue : ( params : {
1819 sessionLengthMs : number
1920 now : Date
@@ -29,6 +30,7 @@ export interface AdmissionDeps {
2930const defaultDeps : AdmissionDeps = {
3031 sweepExpired,
3132 queueDepth,
33+ activeCount,
3234 admitFromQueue,
3335 // FREEBUFF_DEV_FORCE_ADMIT lets local `dev:freebuff` drive the full
3436 // waiting-room → admitted → ended flow without a real upstream.
@@ -48,6 +50,7 @@ export interface AdmissionTickResult {
4850 expired : number
4951 admitted : number
5052 queueDepth : number
53+ activeCount : number
5154 skipped : FireworksHealth | null
5255}
5356
@@ -77,8 +80,17 @@ export async function runAdmissionTick(
7780 getFireworksHealth : deps . getFireworksHealth ,
7881 } )
7982
80- const depth = await deps . queueDepth ( )
81- return { expired, admitted : admitted . length , queueDepth : depth , skipped }
83+ const [ depth , active ] = await Promise . all ( [
84+ deps . queueDepth ( ) ,
85+ deps . activeCount ( ) ,
86+ ] )
87+ return {
88+ expired,
89+ admitted : admitted . length ,
90+ queueDepth : depth ,
91+ activeCount : active ,
92+ skipped,
93+ }
8294}
8395
8496let interval : ReturnType < typeof setInterval > | null = null
@@ -89,17 +101,20 @@ function runTick() {
89101 inFlight = true
90102 runAdmissionTick ( )
91103 . then ( ( result ) => {
92- if ( result . admitted > 0 || result . expired > 0 || result . skipped !== null ) {
93- logger . info (
94- {
95- admitted : result . admitted ,
96- expired : result . expired ,
97- queueDepth : result . queueDepth ,
98- skipped : result . skipped ,
99- } ,
100- '[FreeSessionAdmission] tick' ,
101- )
102- }
104+ // Emit every tick so queueDepth/activeCount form a continuous time-series
105+ // that can be charted over time. metric=freebuff_waiting_room makes it
106+ // filterable in the log aggregator.
107+ logger . info (
108+ {
109+ metric : 'freebuff_waiting_room' ,
110+ admitted : result . admitted ,
111+ expired : result . expired ,
112+ queueDepth : result . queueDepth ,
113+ activeCount : result . activeCount ,
114+ skipped : result . skipped ,
115+ } ,
116+ '[FreeSessionAdmission] tick' ,
117+ )
103118 } )
104119 . catch ( ( error ) => {
105120 logger . warn (
0 commit comments