mco_stat_get_counter_info

Retrieve metadata (name and handle) for a registered runtime statistics counter.

Prototype

    MCO_RET mco_stat_get_counter_info(
        /*IN*/  mco_stat_hdl counter,
        /*OUT*/ mco_stat_counter_info_t *info
    );

Arguments

counter
Handle of the statistics counter (must be in the range 0 to MCO_STATRT_TOTAL_COUNTERS - 1 or a valid custom counter handle).
info
Pointer to a mco_stat_counter_info_t structure that will receive the counter's metadata:
  • handle — the same as the input counter,
  • name — a null-terminated string with the counter's descriptive name.

Description

This function provides introspection into the runtime statistics system. It returns the human-readable name and handle of a given counter, which is essential for diagnostic tools, monitoring dashboards, or logging systems that need to map numeric counter indices to meaningful labels.

For built-in counters (e.g., MCO_STATRT_COMMIT_COUNT), the name is predefined. For custom counters registered via mco_statrt_register_counter(), the name is the one provided during registration.

Return Codes

MCO_S_OK
Counter metadata successfully retrieved.
MCO_E_INVALID_HANDLE
The specified counter handle is out of range or the statistics subsystem is not initialized.

Example

    mco_stat_counter_info_t info;
    MCO_RET rc;

    rc = mco_stat_get_counter_info(MCO_STATRT_COMMIT_COUNT, &info);
    if (rc == MCO_S_OK) {
        printf("Counter %d: %s\n", info.handle, info.name);
    }

Files

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