Skip to main content
Access via:io.insights.metrics

Metrics API.

Properties (2)

Property Type Default Required Description
settings⚓︎ MetricsSettings x

Metrics settings.

started⚓︎ boolean x

Whether or not this instance is started.

5 Methods

get()⚓︎

(name: string) => Metric | undefined

Creates or retrieves a metric by name.

If a metric is already created with this name, it will be returned.

Otherwise, if settings exist for a metric with this name, either provided by the platform or by configuration, a metric will be created.

Otherwise, returns undefined.

Subsequent calls to this method with the same name return the same metric.

Parameters (1)

Name Type Required Description
name⚓︎ string

the name of the metric, e.g. platform_startup

getFromSettings()⚓︎

(settings: MetricSettings) => Metric | undefined

Creates or retrieves a metric based on the provided settings.

If a metric is already created with this name, it will be returned.

Otherwise, if settings exist for a metric with this name, either provided by the platform or by configuration, they will be merged with the settings provided to this method before creating it.

Otherwise, the settings provided will be used as is.

Subsequent calls to this method with the same name return the same metric.

Parameters (1)

Name Type Required Description
settings⚓︎ MetricSettings

settings to use when creating the metric

start()⚓︎

() => Promise<void>

Starts publishing data.

stop()⚓︎

() => Promise<void>

Stops publishing data.

waitForFinalExport()⚓︎

(timeoutMs?: number) => Promise<void>

Waits for any pending data to be published, with the option to specify a timeout.

Parameters (1)

Name Type Required Description
timeoutMs⚓︎ number x

maximum time to wait for export