Module: measured-node-metrics

The main module for the measured-node-metrics lib.

Various functions to help create node metrics and http framework middlewares
that can be used with a self reporting metrics registry to easily instrument metrics for a node app.

Source:

Members


<static> nodeOsMetrics :Object.<string, function()>

Map of metric names and a functions that can be used to generate that metric object that can be registered with a
self reporting metrics registry or used as seen fit.

See nodeOsMetrics.

Type:
  • Object.<string, function()>
Source:

<static> nodeProcessMetrics :Object.<string, function()>

Map of metric names and a functions that can be used to generate that metric object that can be registered with a
self reporting metrics registry or used as seen fit.

See nodeProcessMetrics.

Type:
  • Object.<string, function()>
Source:

Methods


<inner> createExpressMiddleware(metricsRegistry [, reportingIntervalInSeconds])

Creates an Express middleware that reports a timer on request data.
With this middleware you will get requests counts and latency percentiles all filterable by status codes, http method, and uri paths.

Parameters:
Name Type Argument Description
metricsRegistry SelfReportingMetricsRegistry
reportingIntervalInSeconds number <optional>
Source:
Returns:
Type
function

<inner> createExpressMiddleware(metricsRegistry [, reportingIntervalInSeconds])

Creates a Koa middleware that reports a timer on request data.
With this middleware you will get requests counts and latency percentiles all filterable by status codes, http method, and uri paths.

Parameters:
Name Type Argument Description
metricsRegistry SelfReportingMetricsRegistry
reportingIntervalInSeconds number <optional>
Source:
Returns:
Type
function

<inner> createOSMetrics(metricsRegistry, customDimensions, reportingIntervalInSeconds)

Method that can be used to add a set of default node process metrics to your app.

registers all metrics defined in the nodeOsMetrics map.

Parameters:
Name Type Description
metricsRegistry SelfReportingMetricsRegistry
customDimensions Dimensions
reportingIntervalInSeconds number
Source:

<inner> createProcessMetrics(metricsRegistry, customDimensions, reportingIntervalInSeconds)

Method that can be used to add a set of default node process metrics to your node app.

registers all metrics defined in the nodeProcessMetrics map.

Parameters:
Name Type Description
metricsRegistry SelfReportingMetricsRegistry
customDimensions Dimensions
reportingIntervalInSeconds number
Source:

<inner> onRequestEnd(metricsRegistry, stopwatch, method, statusCode [, uri] [, reportingIntervalInSeconds])

When the request ends stop the stop watch and create or update the timer for requests that tracked by method, statuscode, path.
The timers (meters and histograms) that get reported will be filterable by status codes, http method, the uri path.
You will be able to create dash boards such as success percentage, latency percentiles by path and method, etc.

Parameters:
Name Type Argument Description
metricsRegistry

The Self Reporting Metrics Registry

stopwatch

The stopwatch created by onRequestStart

method

The Http Method for the request

statusCode

The status code for the response

uri <optional>

The uri for the request. Please note to avoid out of control time series dimension creation spread,
you would want to strip out ids and or other variables from the uri path.

reportingIntervalInSeconds <optional>

override the reporting interval defaults to every 10 seconds.

Source:

<inner> onRequestStart()

At the start of the request, create a stopwatch, that starts tracking how long the request is taking.

Source:
Returns:
Type
Stopwatch