Update the value of a registered runtime statistics counter using a specified operation.
MCO_RET mco_statrt_update(
/*IN*/ mco_stat_hdl h,
/*IN*/ mco_statrt_op_t op,
/*IN*/ mco_stat_counter_value arg
);
h
mco_statrt_register_counter() or
a built-in constant like MCO_STATRT_COMMIT_COUNT).op
mco_statrt_op_set — set counter to arg,mco_statrt_op_inc — increment by 1 (ignores arg),mco_statrt_op_add — add arg,mco_statrt_op_sub — subtract arg,mco_statrt_op_min — set to minimum of current value and arg,mco_statrt_op_max — set to maximum of current value and arg.arg
mco_statrt_op_inc).This function atomically updates the value of a runtime statistics counter according to the specified operation. It is the primary mechanism for instrumenting application code or internal database components with custom metrics.
If the counter was registered with histogram collection enabled (
collect_histogram = MCO_YES), the new counter value is automatically appended to the associated histogram after the update.The counter must be valid and the statistics subsystem must be initialized (i.e., a database with statistics support must be open).
Note: This function does not return the updated value. Use
mco_statrt_get()ormco_stat_counter_get()to read the current value.
MCO_S_OK
MCO_E_INVALID_HANDLE
MCO_E_ILLEGAL_PARAM
// Increment a built-in counter
mco_statrt_update(MCO_STATRT_COMMIT_COUNT, mco_statrt_op_inc, 0);
// Update a custom counter with max operation
mco_stat_hdl latency_counter = /* previously registered */;
mco_statrt_update(latency_counter, mco_statrt_op_max, measured_latency);
// Add to an error counter
mco_statrt_update(my_error_counter, mco_statrt_op_add, 1);