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

Properties

Protected _counters

_counters: ICounters[] = []

Methods

CompositeCounters

  • CompositeCounters(references?: IReferences): void
  • Creates a new instance of the counters.

    Parameters

    • Default value references: IReferences = null

      references to locate the component dependencies.

    Returns void

beginTiming

  • beginTiming(name: string): Timing

endTiming

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

increment

  • increment(name: string, value: number): 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

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

timestampNow

  • timestampNow(name: string): void

Generated using TypeDoc