Skip to main content

Class: MetricsBuffer

worker.MetricsBuffer

A buffer that can be set on RuntimeOptions.telemetry.metricsExporter to record metrics instead of ignoring/exporting them.

It is important that the buffer size is set to a high number and that retrieveUpdates is called regularly to drain the buffer. If the buffer is full, metric updates will be dropped and an error will be logged.

Buffered metrics is an experimental feature. APIs may be subject to change.

Constructors

constructor

new MetricsBuffer(options?): MetricsBuffer

Parameters

NameType
options?MetricsBufferOptions

Returns

MetricsBuffer

Properties

maxBufferSize

Readonly maxBufferSize: number


useSecondsForDurations

Readonly useSecondsForDurations: boolean

Methods

retrieveUpdates

retrieveUpdates(): ArrayIterator<BufferedMetricUpdate>

Retrieve buffered metric updates.

This method drains the metrics buffer and returns all metric events that have accumulated since the last call to this method. This method should be called regularly when using buffered metrics to prevent buffer overflow.

Returns

ArrayIterator<BufferedMetricUpdate>

Array of buffered metric updates, each containing the metric metadata, current value, and attributes Buffered metrics is an experimental feature. APIs may be subject to change.