Class: ServiceMetricsEmitter

ServiceMetricsEmitter(batchDelay, autoStart, org, environment, logger)

Class representing an AWS cloudwatch metrics emitter with shortcut methods for service specific dimensions and namespaces.

Constructor

new ServiceMetricsEmitter(batchDelay, autoStart, org, environment, logger)

Constructor for ServiceMetricsEmitter
Parameters:
Name Type Description
batchDelay number The number of millisencons to wait before sending the metrics data. If set to null or less than 1, then metrics will be emitted individually.
autoStart bool If true, then the emitter autimatically starts emitting mmetrics after the batch delay.
org string The organisation the metrics are for. This is used to determine the namespace.
environment string Tbe environment the metrics are for. This is added as a dimension to all metrics.
logger Logger The winston logger.
Source:

Methods

addRequestCountMetric(serviceName)

Adds a count for the request to the service in general, irrespective of the end point.
Parameters:
Name Type Description
serviceName string The name of the service; usually the resource name in plural that the service is for.
Source:

addServiceMethodCountMetric(serviceName, method, metricName)

Adds a count metric for a resource service request.
Parameters:
Name Type Description
serviceName string The name of the service; usually the resource name in plural that the service is for.
method string The http method: GET, PUT, etc
metricName string the name of the metric.
Source:

addServiceMetric(serviceName, method, metricName, unit, value)

Adds a service metric to the emitter buffer.
Parameters:
Name Type Description
serviceName string The name of the service; usually the resource name in plural that the service is for.
method string The http method: GET, PUT, etc
metricName string The name of the metric.
unit string The metric unit.
value string The metric value.
Source:

addServiceResponseSizeMetric(serviceName, method, responseSize)

Adds a response size metric for a resource service request.
Parameters:
Name Type Description
serviceName string The name of the service; usually the resource name in plural that the service is for.
method string The http method: GET, PUT, etc
responseSize number the size of the response in bytes.
Source:

addServiceResponseTimeMetric(serviceName, method, responseTime)

Adds a response ellapsed time metric for a resource service request.
Parameters:
Name Type Description
serviceName string The name of the service; usually the resource name in plural that the service is for.
method string The http method: GET, PUT, etc
responseTime number the ellapsed time in millseconds of the response.
Source:

getNamespace(serviceName)

Gets the namespace for metric datums based on the org and service names.
Parameters:
Name Type Description
serviceName srting The name of the service; usually the resource name in plural that the service is for.
Source: