} /* gauge_t *uc_get_rate_by_name */
int uc_get_rate(metric_t const *m, gauge_t *ret) {
+ if (m == NULL || m->family == NULL || ret == NULL) {
+ return EINVAL;
+ }
+ if (m->family->type == METRIC_TYPE_GAUGE) {
+ *ret = m->value.gauge;
+ return 0;
+ }
+
strbuf_t buf = STRBUF_CREATE;
int status = metric_identity(&buf, m);
if (status != 0) {
* occurred by comparing the time returned by `uc_first_metric()` with the
* metric time: in an overflow/reset situation, the values are equal.
*
- * For non-cumulative types (gauge), the last value is returned in `ret_value`.
+ * For non-cumulative types (gauge), the function takes a short cut and returns
+ * `m->value.gauge` in `ret_value`. Since this is a fast operation, plugin
+ * authors are discouraged from writing special cases for gauge metrics.
*
* Returns zero on success, ENOENT if the metric is not in the cache, and
* EAGAIN if the metric has state STATE_MISSING.