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

Constructors

constructor

  • Creates a new CachedCounters object.

    Returns CachedCounters

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

beginTiming

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
  • Clears (resets) all counters.

    Returns 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
  • Dumps (saves) the current values of counters.

    see

    save

    Returns void

endTiming

  • endTiming(name: string, elapsed: number): void
  • Ends measurement of execution elapsed time and updates specified counter.

    see

    CounterTiming.endTiming

    Parameters

    • name: string

      a counter name

    • elapsed: number

      execution elapsed time in milliseconds to update the counter.

    Returns 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

  • Gets all captured counters.

    Returns Counter[]

    a list with counters.

getInterval

  • getInterval(): number
  • Gets the counters dump/save interval.

    Returns number

    the interval in milliseconds.

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
  • Increments counter by 1.

    Parameters

    • name: string

      a counter name of Increment type.

    Returns 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
  • Records the given timestamp.

    Parameters

    • name: string

      a counter name of Timestamp type.

    • value: Date

      a timestamp to record.

    Returns void

timestampNow

  • timestampNow(name: string): void
  • Records the current time as a timestamp.

    Parameters

    • name: string

      a counter name of Timestamp type.

    Returns void

Protected update

  • update(): void
  • Makes counter measurements as updated and dumps them when timeout expires.

    see

    dump

    Returns void

Generated using TypeDoc