From a724d6db906be9d2aa89c7bd8953f7c60f970961 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 14 Dec 2023 12:54:42 +0100 Subject: [PATCH] write_open_telemetry plugin: Take the resource attributes into account when comparing metric families. The `staged_metric_families` tree was only using the metric family's name to stage metrics, which is incorrect with the new resource attributes. The code is now using the new `metric_family_compare` function to take the attributes also into account. --- src/write_open_telemetry.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/write_open_telemetry.cc b/src/write_open_telemetry.cc index a27ed6bdd..669e2b253 100644 --- a/src/write_open_telemetry.cc +++ b/src/write_open_telemetry.cc @@ -234,7 +234,7 @@ static bool ot_metric_is_staged(ot_callback_t *cb, metric_t const *m) { } static bool ot_need_flush(ot_callback_t *cb, metric_family_t const *fam) { - int status = c_avl_get(cb->staged_metric_families, fam->name, NULL); + int status = c_avl_get(cb->staged_metric_families, fam, NULL); if (status != 0) { return false; } @@ -288,7 +288,7 @@ static int ot_mark_metric_staged(ot_callback_t *cb, metric_t const *m) { static metric_family_t *ot_staged_metric_family(ot_callback_t *cb, metric_family_t const *fam) { metric_family_t *ret = NULL; - int status = c_avl_get(cb->staged_metric_families, fam->name, (void **)&ret); + int status = c_avl_get(cb->staged_metric_families, fam, (void **)&ret); if (status == 0) { DEBUG("write_open_telemetry plugin: Found staged metric family \"%s\"", ret->name); @@ -296,7 +296,7 @@ static metric_family_t *ot_staged_metric_family(ot_callback_t *cb, } ret = metric_family_clone_shallow(fam); - c_avl_insert(cb->staged_metric_families, ret->name, ret); + c_avl_insert(cb->staged_metric_families, ret, ret); DEBUG("write_open_telemetry plugin: Successfully staged metric family \"%s\"", ret->name); return ret; @@ -349,7 +349,7 @@ static int ot_config_node(oconfig_item_t *ci) { cb->staged_metrics = c_avl_create((int (*)(const void *, const void *))strcmp); cb->staged_metric_families = - c_avl_create((int (*)(const void *, const void *))strcmp); + c_avl_create((int (*)(const void *, const void *))metric_family_compare); pthread_mutex_init(&cb->mu, /* attr = */ NULL); -- 2.39.5