# MetricsManager

**Kind**: interface | **Module**: [Insights](https://docs.interop.io/desktop/reference/javascript/insights/index.md) | **Access**: `io.insights.metrics`

**Source**: https://docs.interop.io/desktop/reference/javascript/insights/metricsmanager/index.html

Metrics API.

## Properties

- **`settings`** (`MetricsSettings`, required)
  Metrics settings.
- **`started`** (`boolean`, required)
  Whether or not this instance is started.

## Methods

### get

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.

```ts
(name: string) => Metric | undefined
```

**Parameters**

- **`name`** (`string`, required)
  the name of the metric, e.g. platform_startup

**Returns**: `Metric | undefined`

### getFromSettings

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.

```ts
(settings: MetricSettings) => Metric | undefined
```

**Parameters**

- **`settings`** (`MetricSettings`, required)
  settings to use when creating the metric

**Returns**: `Metric | undefined`

### start

Starts publishing data.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### stop

Stops publishing data.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### waitForFinalExport

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

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

**Parameters**

- **`timeoutMs`** (`number`, optional)
  maximum time to wait for export

**Returns**: `Promise<void>`

## Related types

- [Metric](https://docs.interop.io/desktop/reference/javascript/insights/metric/index.md)
- [MetricSettings](https://docs.interop.io/desktop/reference/javascript/insights/metricsettings/index.md)
- [MetricsSettings](https://docs.interop.io/desktop/reference/javascript/insights/metricssettings/index.md)
