@@ -7,7 +7,12 @@ import {
77 isWaitingRoomEnabled ,
88} from './config'
99import { getFleetHealth } from './fireworks-health'
10- import { activeCount , admitFromQueue , queueDepth , sweepExpired } from './store'
10+ import {
11+ activeCountsByModel ,
12+ admitFromQueue ,
13+ queueDepth ,
14+ sweepExpired ,
15+ } from './store'
1116
1217import type { FireworksHealth , FleetHealth } from './fireworks-health'
1318
@@ -16,7 +21,7 @@ import { logger } from '@/util/logger'
1621export interface AdmissionDeps {
1722 sweepExpired : ( now : Date , graceMs : number ) => Promise < number >
1823 queueDepth : ( params : { model : string } ) => Promise < number >
19- activeCount : ( ) => Promise < number >
24+ activeCountsByModel : ( ) => Promise < Record < string , number > >
2025 admitFromQueue : ( params : {
2126 model : string
2227 sessionLengthMs : number
@@ -35,7 +40,7 @@ export interface AdmissionDeps {
3540const defaultDeps : AdmissionDeps = {
3641 sweepExpired,
3742 queueDepth,
38- activeCount ,
43+ activeCountsByModel ,
3944 admitFromQueue,
4045 // FREEBUFF_DEV_FORCE_ADMIT lets local `dev:freebuff` drive the full
4146 // waiting-room → admitted → ended flow without a real upstream. Returning
@@ -58,7 +63,9 @@ export interface AdmissionTickResult {
5863 admitted : number
5964 /** Per-model queue depth at the end of the tick. */
6065 queueDepthByModel : Record < string , number >
61- activeCount : number
66+ /** Per-model active-session count at the end of the tick. Models with no
67+ * active sessions are omitted. */
68+ activeCountByModel : Record < string , number >
6269 skipped : FireworksHealth | null
6370}
6471
@@ -106,7 +113,7 @@ export async function runAdmissionTick(
106113 } ) ,
107114 )
108115
109- const active = await deps . activeCount ( )
116+ const activeCountByModel = await deps . activeCountsByModel ( )
110117 const totalAdmitted = perModel . reduce ( ( s , r ) => s + r . admittedCount , 0 )
111118 const queueDepthByModel = Object . fromEntries (
112119 perModel . map ( ( r ) => [ r . model , r . depth ] ) ,
@@ -117,7 +124,7 @@ export async function runAdmissionTick(
117124 expired,
118125 admitted : totalAdmitted ,
119126 queueDepthByModel,
120- activeCount : active ,
127+ activeCountByModel ,
121128 skipped,
122129 }
123130}
@@ -130,16 +137,16 @@ function runTick() {
130137 inFlight = true
131138 runAdmissionTick ( )
132139 . then ( ( result ) => {
133- // Emit every tick so queueDepth/activeCount form a continuous time-series
134- // that can be charted over time. metric=freebuff_waiting_room makes it
135- // filterable in the log aggregator.
140+ // Emit every tick so per-model queue depth and active counts form a
141+ // continuous time-series that can be charted over time.
142+ // metric=freebuff_waiting_room makes it filterable in the log aggregator.
136143 logger . info (
137144 {
138145 metric : 'freebuff_waiting_room' ,
139146 admitted : result . admitted ,
140147 expired : result . expired ,
141148 queueDepthByModel : result . queueDepthByModel ,
142- activeCount : result . activeCount ,
149+ activeCountByModel : result . activeCountByModel ,
143150 skipped : result . skipped ,
144151 } ,
145152 '[FreeSessionAdmission] tick' ,
0 commit comments