@@ -14,7 +14,7 @@ import * as zlib from 'zlib'
14
14
15
15
import { PageStatsNames , RtcStatsMetricNames , parseRtStatKey } from './rtcstats'
16
16
import { Session } from './session'
17
- import { Scheduler , hideAuth , logger , toPrecision } from './utils'
17
+ import { Scheduler , enabledForSession , hideAuth , logger , toPrecision } from './utils'
18
18
19
19
export { FastStats }
20
20
@@ -321,7 +321,7 @@ export class Stats extends events.EventEmitter {
321
321
readonly rtcStatsTimeout : number
322
322
readonly customMetrics : Record < string , { labels ?: string [ ] } > = { }
323
323
readonly startTimestamp : number
324
- readonly enableDetailedStats : boolean
324
+ readonly enableDetailedStats : boolean | string | number
325
325
private readonly startTimestampString : string
326
326
327
327
readonly sessions = new Map < number , Session > ( )
@@ -443,7 +443,7 @@ export class Stats extends events.EventEmitter {
443
443
serverSecret : string
444
444
startSessionId : number
445
445
startTimestamp : number
446
- enableDetailedStats : boolean
446
+ enableDetailedStats : boolean | string | number
447
447
customMetricsLabels ?: string
448
448
} ) {
449
449
super ( )
@@ -715,7 +715,7 @@ export class Stats extends events.EventEmitter {
715
715
alertRules : { } ,
716
716
}
717
717
718
- if ( this . enableDetailedStats ) {
718
+ if ( this . enableDetailedStats !== false ) {
719
719
this . metrics [ name ] . value = promCreateGauge ( register , name , '' , [
720
720
'participantName' ,
721
721
'trackId' ,
@@ -801,7 +801,7 @@ export class Stats extends events.EventEmitter {
801
801
Object . values ( stats . byCodec ) . forEach ( s => s . reset ( ) )
802
802
stats . byParticipantAndTrack = { }
803
803
} )
804
- for ( const session of this . sessions . values ( ) ) {
804
+ for ( const [ sessionId , session ] of this . sessions . entries ( ) ) {
805
805
this . collectedStatsConfig . url = `${ hideAuth ( session . url ) } ?${ session . urlQuery } `
806
806
this . collectedStatsConfig . pages += session . pages . size || 0
807
807
const sessionStats = await session . updateStats ( )
@@ -827,7 +827,7 @@ export class Stats extends events.EventEmitter {
827
827
}
828
828
stats . push ( value )
829
829
// Push participant and track values.
830
- if ( this . enableDetailedStats && participantName ) {
830
+ if ( enabledForSession ( sessionId , this . enableDetailedStats ) && participantName ) {
831
831
collectedStats . byParticipantAndTrack [ `${ participantName } :${ trackId || '' } ` ] = value
832
832
}
833
833
} else if ( typeof value === 'string' ) {
0 commit comments