Class Stats

Hierarchy

  • EventEmitter
    • Stats

Index

Constructors

constructor

  • new Stats(initialCounters: string[], options: any): Stats

Properties

Private _applyOp

_applyOp: any

For the given operation, op, the stats and frequencyAccumulator will be updated or initialized if they don't already exist.

param

op

throws

{InvalidNumber}

returns

_frequencyAccumulators

_frequencyAccumulators: {}

Type declaration

_frequencyLastTime

_frequencyLastTime: number

_movingAverages

_movingAverages: {}

Type declaration

Private _nextTimeout

_nextTimeout: any

Calculates and returns the timeout for the next update based on the urgency of the update.

returns

_options

_options: any

_queue

_queue: any[]

Private _resetComputeTimeout

_resetComputeTimeout: any

Resets the timeout for triggering updates.

returns

_stats

_stats: {}

Type declaration

_timeout

_timeout: any

Private _update

_update: any

If there are items in the queue, they will will be processed and the frequency for all items will be updated based on the Timestamp of the last item in the queue. The update event will also be emitted with the latest stats.

If there are no items in the queue, no action is taken.

returns

Private _updateFrequency

_updateFrequency: any

For each key in the stats, the frequency and moving averages will be updated via Stats._updateFrequencyFor based on the time difference between calls to this method.

param
returns

Private _updateFrequencyFor

_updateFrequencyFor: any

Updates the movingAverages for the given key and also resets the frequencyAccumulator for the key.

param
param

Time in milliseconds

param

Time in ticks

returns

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: unique symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

movingAverages

  • get movingAverages(): any
  • Returns a clone of the internal movingAverages

    Returns any

snapshot

  • get snapshot(): any
  • Returns a clone of the current stats.

    Returns any

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number

listenerCount

  • listenerCount(event: string | symbol): number

listeners

  • listeners(event: string | symbol): Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

push

  • push(counter: string, inc: number): void
  • Pushes the given operation data to the queue, along with the current Timestamp, then resets the update timer.

    Parameters

    • counter: string
    • inc: number

    Returns void

rawListeners

  • rawListeners(event: string | symbol): Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this

start

  • start(): void
  • Initializes the internal timer if there are items in the queue. This should only need to be called if Stats.stop was previously called, as Stats.push will also start the processing.

    Returns void

stop

  • stop(): void
  • Stops processing and computing of stats by clearing the internal timer.

    Returns void

toJSON

  • toJSON(): any
  • Returns a plain JSON object of the stats

    Returns any

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number