char name[6 * DATA_MAX_NAME_LEN];
distribution_t *distribution_increase;
gauge_t values_gauge;
- value_t values_raw;
+ typed_value_t values_raw;
/* Time contained in the package
* (for calculating rates) */
cdtime_t last_time;
ce->distribution_increase = NULL;
ce->values_gauge = 0;
- ce->values_raw = (value_t){.gauge = 0};
+ ce->values_raw = typed_value_create((value_t){.gauge = 0}, METRIC_TYPE_GAUGE);
ce->history = NULL;
ce->history_length = 0;
ce->meta = NULL;
switch (m->family->type) {
case DS_TYPE_COUNTER:
ce->values_gauge = NAN;
- ce->values_raw.counter = m->value.counter;
+ ce->values_raw = typed_value_create(m->value, METRIC_TYPE_COUNTER);
ce->distribution_increase = NULL;
ce->start_value = typed_value_create(m->value, METRIC_TYPE_COUNTER);
break;
case DS_TYPE_GAUGE:
ce->values_gauge = m->value.gauge;
- ce->values_raw.gauge = m->value.gauge;
+ ce->values_raw = typed_value_create(m->value, METRIC_TYPE_GAUGE);
ce->distribution_increase = NULL;
ce->start_value = typed_value_create(m->value, METRIC_TYPE_GAUGE);
break;
case DS_TYPE_DERIVE:
ce->values_gauge = NAN;
- ce->values_raw.derive = m->value.derive;
+ //ce->values_raw.derive = m->value.derive;
ce->distribution_increase = NULL;
/* TODO: METRIC_TYPE_DERIVE? */
break;
case DS_TYPE_DISTRIBUTION:
ce->values_gauge = NAN;
- ce->values_raw.distribution = distribution_clone(m->value.distribution);
+ ce->values_raw = typed_value_create(m->value, METRIC_TYPE_DISTRIBUTION);
ce->distribution_increase = distribution_clone(m->value.distribution);
ce->start_value = typed_value_create(m->value, METRIC_TYPE_DISTRIBUTION);
break;
switch (m->family->type) {
case METRIC_TYPE_COUNTER: {
- counter_t diff = counter_diff(ce->values_raw.counter, m->value.counter);
+ counter_t diff = counter_diff(ce->values_raw.value.counter, m->value.counter);
ce->values_gauge =
((double)diff) / (CDTIME_T_TO_DOUBLE(m->time - ce->last_time));
- ce->values_raw.counter = m->value.counter;
+ ce->values_raw.value.counter = m->value.counter;
break;
}
case METRIC_TYPE_UNTYPED:
case METRIC_TYPE_GAUGE: {
- ce->values_raw.gauge = m->value.gauge;
+ ce->values_raw.value.gauge = m->value.gauge;
ce->values_gauge = m->value.gauge;
break;
}
distribution_destroy(ce->distribution_increase);
ce->distribution_increase = distribution_clone(m->value.distribution);
int status = distribution_sub(ce->distribution_increase,
- ce->values_raw.distribution);
+ ce->values_raw.value.distribution);
if (status == ERANGE) {
distribution_destroy(ce->distribution_increase);
ce->distribution_increase = distribution_clone(m->value.distribution);
ERROR("uc_update: distribution_sub failed with status %d.", status);
return status;
}
- distribution_destroy(ce->values_raw.distribution);
- ce->values_raw.distribution = distribution_clone(m->value.distribution);
+ distribution_destroy(ce->values_raw.value.distribution);
+ ce->values_raw.value.distribution = distribution_clone(m->value.distribution);
break;
}
#if 0
status = -1;
} else {
if (ce->distribution_increase == NULL &&
- ce->values_raw.distribution !=
+ ce->values_raw.value.distribution !=
NULL) { /* check if the cache entry is not the distribution */
pthread_mutex_unlock(&cache_lock);
ERROR("uc_get_percentile: Don't know how to handle data source type "
} else {
if (ce->distribution_increase == NULL &&
- ce->values_raw.distribution !=
+ ce->values_raw.value.distribution !=
NULL) { /* check if the cache entry is not the distribution */
*ret_values = ce->values_gauge;
} else { /* in case where metric is a distribution, we
if (ce->state == STATE_MISSING) {
status = -1;
} else {
- *ret_values = ce->values_raw;
+ *ret_values = typed_value_clone(ce->values_raw).value;
}
} else {
DEBUG("utils_cache: uc_get_value_by_name: No such value: %s", name);
if ((iter == NULL) || (iter->entry == NULL) || (ret_values == NULL))
return -1;
- *ret_values = iter->entry->values_raw;
+ *ret_values = typed_value_clone(iter->entry->values_raw).value;
return 0;
} /* int uc_iterator_get_values */