Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CompositeCounters

Aggregates all counters from component references under a single component.

It allows to capture metrics and conveniently send them to multiple destinations.

References

  • *:counters:*:*:1.0 (optional) ICounters components to pass collected measurements
see

ICounters

Example

class MyComponent implements IReferenceable {
    private _counters: CompositeCounters = new CompositeCounters();

    public setReferences(references: IReferences): void {
        this._counters.setReferences(references);
        ...
    }

    public myMethod(): void {
        this._counters.increment("mycomponent.mymethod.calls");
        var timing = this._counters.beginTiming("mycomponent.mymethod.exec_time");
        try {
            ...
        } finally {
            timing.endTiming();
        }
    }
}

Hierarchy

  • CompositeCounters

Implements

Index

Constructors

constructor

  • Creates a new instance of the counters.

    Parameters

    • Default value references: IReferences = null

      references to locate the component dependencies.

    Returns CompositeCounters

Properties

Protected _counters

_counters: ICounters[] = []

Methods

beginTiming

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

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

setReferences

  • setReferences(references: IReferences): void
  • Sets references to dependent components.

    Parameters

    • references: IReferences

      references to locate the component dependencies.

    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

Generated using TypeDoc