Class: SelfReportingMetricsRegistry

SelfReportingMetricsRegistry

A dimensional aware self-reporting metrics registry


new SelfReportingMetricsRegistry(reporters [, options])

Parameters:
Name Type Argument Description
reporters Reporter | Array.<Reporter>

A single Reporter or an array of reporters that will be used to report metrics on an interval.

options SelfReportingMetricsRegistryOptions <optional>

Configurable options for the Self Reporting Metrics Registry

Source:

Members


<protected> _log :Logger

Loggers to use, defaults to a new console logger if nothing is supplied in options

Type:
  • Logger
Source:

<protected> _registry :DimensionAwareMetricsRegistry

Type:
Source:

<protected> _reporters :Reporter

Type:
Source:

Methods


getOrCreateCachedGauge(name [, dimensions] [, publishingIntervalInSeconds])

Creates a CachedGauge or gets the existing CachedGauge for a given name and dimension combo.

Parameters:
Name Type Argument Description
name string

The Metric name.

valueProducingPromiseCallback. function
cachedGaugeUpdateIntervalInSeconds. number
dimensions Dimensions <optional>

any custom Dimensions for the Metric.

publishingIntervalInSeconds number <optional>

a optional custom publishing interval.

Source:
Returns:
Type
CachedGauge

getOrCreateCounter(name [, dimensions] [, publishingIntervalInSeconds])

Creates a Counter or gets the existing Counter for a given name and dimension combo

Parameters:
Name Type Argument Description
name string

The Metric name

dimensions Dimensions <optional>

any custom Dimensions for the Metric

publishingIntervalInSeconds number <optional>

a optional custom publishing interval

Source:
Returns:
Type
Counter

getOrCreateGauge(name, callback [, dimensions] [, publishingIntervalInSeconds])

Creates a Gauge or gets the existing Gauge for a given name and dimension combo

Parameters:
Name Type Argument Description
name string

The Metric name

callback function

The callback that will return a value to report to signal fx

dimensions Dimensions <optional>

any custom Dimensions for the Metric

publishingIntervalInSeconds number <optional>

a optional custom publishing interval

Source:
Returns:
Type
Gauge
Example
// https://nodejs.org/api/process.html#process_process_memoryusage
// Report heap total and heap used at the default interval
registry.getOrCreateGauge(
  'process-memory-heap-total',
  () => {
    return process.memoryUsage().heapTotal
  }
);
registry.getOrCreateGauge(
  'process-memory-heap-used',
  () => {
    return process.memoryUsage().heapUsed
  }
)

getOrCreateHistogram(name [, dimensions] [, publishingIntervalInSeconds])

Creates a Histogram or gets the existing Histogram for a given name and dimension combo

Parameters:
Name Type Argument Description
name string

The Metric name

dimensions Dimensions <optional>

any custom Dimensions for the Metric

publishingIntervalInSeconds number <optional>

a optional custom publishing interval

Source:
Returns:
Type
Histogram

getOrCreateMeter(name [, dimensions] [, publishingIntervalInSeconds])

Creates a Meter or gets the existing Meter for a given name and dimension combo

Parameters:
Name Type Argument Description
name string

The Metric name

dimensions Dimensions <optional>

any custom Dimensions for the Metric

publishingIntervalInSeconds number <optional>

a optional custom publishing interval

Source:
Returns:
Type
Meter

getOrCreateSettableGauge(name [, dimensions] [, publishingIntervalInSeconds])

Creates a SettableGauge or gets the existing SettableGauge for a given name and dimension combo.

Parameters:
Name Type Argument Description
name string

The Metric name

dimensions Dimensions <optional>

any custom Dimensions for the Metric

publishingIntervalInSeconds number <optional>

a optional custom publishing interval

Source:
Returns:
Type
SettableGauge

getOrCreateTimer(name [, dimensions] [, publishingIntervalInSeconds])

Creates a Timer or gets the existing Timer for a given name and dimension combo.

Parameters:
Name Type Argument Description
name string

The Metric name

dimensions Dimensions <optional>

any custom Dimensions for the Metric

publishingIntervalInSeconds number <optional>

a optional custom publishing interval

Source:
Returns:
Type
Timer

register(name, metric [, dimensions] [, publishingIntervalInSeconds])

Registers a manually created Metric.

Parameters:
Name Type Argument Description
name string

The Metric name

metric Metric

The Metric to register

dimensions Dimensions <optional>

any custom Dimensions for the Metric

publishingIntervalInSeconds number <optional>

a optional custom publishing interval

Source:
Example
const settableGauge = new SettableGauge(5);
// register the gauge and have it report to every 10 seconds
registry.register('my-gauge', settableGauge, {}, 10);
interval(() => {
   // such as cpu % used
   determineAValueThatCannotBeSync((value) => {
     settableGauge.update(value);
   })
}, 10000)

shutdown()

Calls end on all metrics in the registry that support end() and calls end on the reporter

Source: