# eXtremeDB Performance Monitor C API

> The Performance Monitor C API provides a set of functions for integrating runtime performance monitoring into an application. The typical workflow involves:

> 1. Initializing the monitor by allocating memory for the internal `perfmon` database and passing the memory segment to `mco_perfmon_init()`.
> 2. Attaching an eXtremeDB database to be monitored via `mco_perfmon_attach()`.
> 3. Performing database operations while metrics are collected.
> 4. Detaching the database with `mco_perfmon_detach()` and shutting down the monitor using `mco_perfmon_close()`.

> At any time after initialization, the application can configure monitor behavior using the following options:

> `enabled`
> Enables or disables metric collection. `0` = disabled, `1` = enabled (default: `1`).
> `monitor_interval_ms`
> Sampling interval for metric collection, in milliseconds (default: `1000` ms = 1 second).
> `store_interval_sec`
> Retention period for metrics in the perfmon database, in seconds (default: `3600` s). Older records are automatically purged to conserve space.

> To retrieve the current configuration, call `mco_perfmon_get_options()`, which returns an options structure. To update settings, modify the structure and pass it to `mco_perfmon_set_options()`.

> After attaching a database, the name of the internal perfmon database (where metrics are stored) can be obtained at any time by calling `mco_perfmon_get_db_name()`.