metric = ucl_object_typed_new (UCL_OBJECT);
- ucl_object_insert_key (top, metric,
- metric_name, strlen (metric_name), true);
+ ucl_object_insert_key (metric, ucl_object_fromstring (metric_name),
+ "metric", sizeof ("metric") - 1, true);
ucl_object_insert_key (metric, ucl_object_typed_new (UCL_ARRAY),
"actions", sizeof ("actions") - 1, false);
ucl_object_insert_key (metric, ucl_object_typed_new (UCL_ARRAY),
"symbols", sizeof ("symbols") - 1, false);
+ ucl_array_append (top, metric);
+
return metric;
}
return NULL;
}
+static ucl_object_t *
+dynamic_metric_find_metric (const ucl_object_t *arr, const gchar *metric)
+{
+ ucl_object_iter_t it = NULL;
+ const ucl_object_t *cur, *n;
+
+ while ((cur = ucl_iterate_object (arr, &it, true)) != NULL) {
+ if (cur->type == UCL_OBJECT) {
+ n = ucl_object_find_key (cur, "metric");
+ if (n && n->type == UCL_STRING &&
+ strcmp (metric, ucl_object_tostring (n)) == 0) {
+ return (ucl_object_t *)cur;
+ }
+ }
+ }
+
+ return NULL;
+}
+
static ucl_object_t *
new_dynamic_elt (ucl_object_t *arr, const gchar *name, gdouble value)
{
return FALSE;
}
- metric = (ucl_object_t *)ucl_object_find_key (cfg->current_dynamic_conf,
+ metric = dynamic_metric_find_metric (cfg->current_dynamic_conf,
metric_name);
if (metric == NULL) {
metric = new_dynamic_metric (metric_name, cfg->current_dynamic_conf);
}
- syms = (ucl_object_t *)ucl_object_find_key (cfg->current_dynamic_conf,
- "symbols");
+ syms = (ucl_object_t *)ucl_object_find_key (metric, "symbols");
if (syms != NULL) {
ucl_object_t *sym;
return FALSE;
}
- metric = (ucl_object_t *)ucl_object_find_key (cfg->current_dynamic_conf,
+ metric = dynamic_metric_find_metric (cfg->current_dynamic_conf,
metric_name);
if (metric == NULL) {
metric = new_dynamic_metric (metric_name, cfg->current_dynamic_conf);
}
- acts = (ucl_object_t *)ucl_object_find_key (cfg->current_dynamic_conf,
- "actions");
+ acts = (ucl_object_t *)ucl_object_find_key (metric, "actions");
if (acts != NULL) {
ucl_object_t *act;