mco_stat_get_histogram_source

Retrieve the internal histogram index associated with a given statistics counter.

Prototype

    MCO_RET mco_stat_get_histogram_source(
        /*IN*/  mco_stat_hdl counter,
        /*OUT*/ mco_stat_hdl *source
    );

Arguments

counter
Handle of the statistics counter to query.
source
Pointer to a variable that will receive the internal histogram index. If the counter does not have histogram collection enabled, the value is set to MCO_STAT_INVALID_HANDLE.

Description

This function maps a statistics counter to its corresponding histogram storage index. It is primarily used by diagnostic or monitoring tools that need to access raw histogram data via mco_stat_histogram_get().

Only counters registered with collect_histogram = MCO_YES (via mco_statrt_register_counter()) have an associated histogram. For all other counters, this function returns MCO_STAT_INVALID_HANDLE in the source parameter.

Note: The statistics subsystem must be initialized (i.e., a database with statistics support must be open) before calling this function.

Return Codes

MCO_S_OK
Operation completed successfully. The source parameter contains the histogram index or MCO_STAT_INVALID_HANDLE.
MCO_E_INVALID_HANDLE
The specified counter handle is out of range or the statistics subsystem is not initialized.

Example

    mco_stat_hdl hist_idx;
    MCO_RET rc;

    rc = mco_stat_get_histogram_source(MCO_STATRT_MAX_TRANS_TIME, &hist_idx);
    if (rc == MCO_S_OK && hist_idx != MCO_STAT_INVALID_HANDLE) {
        mco_stat_histogram_h hist;
        mco_stat_histogram_get(hist_idx, &hist);
        printf("Histogram range: %u\n", hist->range);
    }

Files

Header file:
mcostatrt.h
Source file:
mcostat.c
Library:
libmcolib.a