Retrieve a pointer to a specific histogram by its internal index.
MCO_RET mco_stat_histogram_get(
/*IN*/ mco_stat_hdl hist_idx,
/*OUT*/ mco_stat_histogram_h *ret_hist
);
hist_idx
mco_stat_get_histogram_source()).ret_hist
mco_stat_histogram_t structure.This function provides direct access to a histogram stored in the database's statistics memory region. It is typically used after obtaining a valid histogram index from
mco_stat_get_histogram_source().The returned pointer points to internal runtime data and remains valid as long as the database is open. The histogram contains distribution data (e.g., transaction durations) collected automatically when a counter with histogram support is updated.
Applications should not modify the histogram data directly. The structure is intended for read-only inspection (e.g., by monitoring tools or diagnostic utilities).
Note: The statistics subsystem must be initialized (i.e., a database with statistics support must be open) before calling this function.
MCO_S_OK
MCO_E_INVALID_HANDLE
mco_stat_hdl hist_idx;
mco_stat_histogram_h hist;
MCO_RET rc;
// Assume we have a counter with histogram enabled
rc = mco_stat_get_histogram_source(MCO_STATRT_MAX_TRANS_TIME, &hist_idx);
if (rc == MCO_S_OK && hist_idx != MCO_STAT_INVALID_HANDLE) {
rc = mco_stat_histogram_get(hist_idx, &hist);
if (rc == MCO_S_OK) {
printf("Histogram range: %u\n", hist->range);
printf("Total samples: %u\n",
hist->bars[0] + hist->bars[1] + ... ); // sum all bars
}
}