Attaches a database to the Performance Monitor for runtime metric collection.
MCO_RET mco_perfmon_attach(/*IN*/ const char *dbName);
dbName
This function registers the specified database with the Performance Monitor so that runtime metrics (e.g., transaction counts, cache usage, I/O latency) are collected and stored in the internal perfmon database.
The Performance Monitor must be initialized with
mco_perfmon_init()before calling this function.
MCO_S_OK
MCO_E_PERFMON_NOT_INITIALIZED
mco_perfmon_init() first.
#define PERF_DATABASE_SEGMENT_SIZE (64 << 20) /* 64 MB */
const char* dbName = "SimpleDb";
int main(int argc, char* argv[])
{
mco_db_h db;
MCO_RET rc;
void *perf_memory;
// Allocate memory for the perfmon database
perf_memory = malloc(PERF_DATABASE_SEGMENT_SIZE);
if (!perf_memory) { /* handle error */ }
// Initialize Performance Monitor
rc = mco_perfmon_init(perf_memory, PERF_DATABASE_SEGMENT_SIZE);
if (rc != MCO_S_OK) { /* handle error */ }
// Attach target database for monitoring
rc = mco_perfmon_attach(dbName);
if (rc != MCO_S_OK) { /* handle error */ }
// Connect to the database (now being monitored)
rc = mco_db_connect(dbName, &db);
if (rc != MCO_S_OK) { /* handle error */ }
// ... perform monitored operations ...
return 0;
}