Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CloudWatchCounters

Performance counters that periodically dumps counters to AWS Cloud Watch Metrics.

Configuration parameters

  • connections:
    • discovery_key: (optional) a key to retrieve the connection from IDiscovery
    • region: (optional) AWS region
  • credentials:
    • store_key: (optional) a key to retrieve the credentials from ICredentialStore
    • access_id: AWS access/client id
    • access_key: AWS access/client id
  • 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)

References

  • *:context-info:*:*:1.0 (optional) ContextInfo to detect the context id and specify counters source
  • *:discovery:*:*:1.0 (optional) IDiscovery services to resolve connections
  • *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials
see

Counter (in the Pip.Services components package)

see

CachedCounters (in the Pip.Services components package)

see

CompositeLogger (in the Pip.Services components package)

Example

let counters = new CloudWatchCounters();
counters.config(ConfigParams.fromTuples(
    "connection.region", "us-east-1",
    "connection.access_id", "XXXXXXXXXXX",
    "connection.access_key", "XXXXXXXXXXX"
));
counters.setReferences(References.fromTuples(
    new Descriptor("pip-services", "logger", "console", "default", "1.0"),
    new ConsoleLogger()
));

counters.open("123", (err) => {
    ...
});

counters.increment("mycomponent.mymethod.calls");
let timing = counters.beginTiming("mycomponent.mymethod.exec_time");
try {
    ...
} finally {
    timing.endTiming();
}

counters.dump();

Hierarchy

Implements

  • any
  • any

Index

Constructors

constructor

  • Creates a new instance of this counters.

    Returns CloudWatchCounters

Methods

close

  • close(correlationId: string, callback: function): void
  • Closes component and frees used resources.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives error or null no errors occured.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

configure

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

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

isOpen

  • isOpen(): boolean
  • Checks if the component is opened.

    Returns boolean

    true if the component has been opened and false otherwise.

open

  • open(correlationId: string, callback: function): void
  • Opens the component.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives error or null no errors occured.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

Protected save

  • save(counters: Counter[]): void
  • Saves the current counters measurements.

    Parameters

    • counters: Counter[]

      current counters measurements to be saves.

    Returns void

setReferences

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

    see

    IReferences (in the Pip.Services commons package)

    Parameters

    • references: IReferences

      references to locate the component dependencies.

    Returns void

Generated using TypeDoc