Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CachedCounters

Abstract implementation of performance counters that measures and stores counters in memory. Child classes implement saving of the counters into various destinations.

Configuration parameters

  • options:
    • interval: interval in milliseconds to save current counters measurements (default: 5 mins)
    • reset_timeout: timeout in milliseconds to reset the counters. 0 disables the reset (default: 0)

Hierarchy

Implements

Index

Properties

Protected _cache

_cache: object

Type declaration

Protected _interval

_interval: number = 300000

Protected _lastDumpTime

_lastDumpTime: number = new Date().getTime()

Protected _lastResetTime

_lastResetTime: number = new Date().getTime()

Protected _resetTimeout

_resetTimeout: number = 0

Protected _updated

_updated: boolean

Methods

CachedCounters

  • CachedCounters(): void

beginTiming

  • beginTiming(name: string): Timing

clear

  • clear(name: string): void
  • Clears (resets) a counter specified by its name.

    Parameters

    • name: string

      a counter name to clear.

    Returns void

clearAll

  • clearAll(): void

configure

  • configure(config: ConfigParams): void
  • Configures component by passing configuration parameters.

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

dump

  • dump(): void

endTiming

  • endTiming(name: string, elapsed: number): void

get

  • Gets a counter specified by its name. It counter does not exist or its type doesn't match the specified type it creates a new one.

    Parameters

    • name: string

      a counter name to retrieve.

    • type: CounterType

      a counter type.

    Returns Counter

    an existing or newly created counter of the specified type.

getAll

getInterval

  • getInterval(): number

increment

  • increment(name: string, value: number): void
  • Increments counter by given value.

    Parameters

    • name: string

      a counter name of Increment type.

    • value: number

      a value to add to the counter.

    Returns void

incrementOne

  • incrementOne(name: string): void

last

  • last(name: string, value: number): void
  • Records the last calculated measurement value.

    Usually this method is used by metrics calculated externally.

    Parameters

    • name: string

      a counter name of Last type.

    • value: number

      a last value to record.

    Returns void

Protected Abstract save

  • Saves the current counters measurements.

    Parameters

    • counters: Counter[]

      current counters measurements to be saves.

    Returns void

setInterval

  • setInterval(value: number): void
  • Sets the counters dump/save interval.

    Parameters

    • value: number

      a new interval in milliseconds.

    Returns void

stats

  • stats(name: string, value: number): void
  • Calculates min/average/max statistics based on the current and previous values.

    Parameters

    • name: string

      a counter name of Statistics type

    • value: number

      a value to update statistics

    Returns void

timestamp

  • timestamp(name: string, value: Date): void

timestampNow

  • timestampNow(name: string): void

Protected update

  • update(): void

Generated using TypeDoc