Пример #1
0
/**
 * Adds a new sampled value
 * arg type The type of the metrics
 * @arg name The name of the metric
 * @arg val The sample to add
 * @return 0 on success.
 */
int metrics_add_sample(metrics *m, metric_type type, char *name, double val) {
    switch (type) {
        case KEY_VAL:
            return metrics_add_kv(m, name, val);

        case COUNTER:
            return metrics_increment_counter(m, name, val);

        case TIMER:
            return metrics_add_timer_sample(m, name, val);

        default:
            return -1;
    }
}
Пример #2
0
/**
 * Adds a new sampled value
 * arg type The type of the metrics
 * @arg name The name of the metric
 * @arg val The sample to add
 * @return 0 on success.
 */
int metrics_add_sample(metrics *m, metric_type type, char *name, double val, double sample_rate) {
    switch (type) {
        case KEY_VAL:
            return metrics_add_kv(m, name, val);

        case GAUGE:
            return metrics_set_gauge(m, name, val, false);

        case GAUGE_DELTA:
            return metrics_set_gauge(m, name, val, true);

        case COUNTER:
            return metrics_increment_counter(m, name, val, sample_rate);

        case TIMER:
            return metrics_add_timer_sample(m, name, val, sample_rate);

        default:
            return -1;
    }
}