From 0ba19ce306d56191185349a80c609d975b106921 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 22 Nov 2024 18:06:15 +0900 Subject: [PATCH] processor_labels: Process operations for output purposed contexts of metrics instead of the original one Signed-off-by: Hiroshi Hatake --- plugins/processor_labels/labels.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/plugins/processor_labels/labels.c b/plugins/processor_labels/labels.c index ee34e639f25..a0afd8314d4 100644 --- a/plugins/processor_labels/labels.c +++ b/plugins/processor_labels/labels.c @@ -1713,44 +1713,41 @@ static int cb_process_metrics(struct flb_processor_instance *processor_instance, return FLB_PROCESSOR_FAILURE; } - result = delete_labels(metrics_context, + result = cmt_cat(out_cmt, metrics_context); + if (result != 0) { + cmt_destroy(out_cmt); + + return FLB_PROCESSOR_FAILURE; + } + + result = delete_labels(out_cmt, &processor_context->delete_labels); if (result == FLB_PROCESSOR_SUCCESS) { - result = update_labels(metrics_context, + result = update_labels(out_cmt, &processor_context->update_labels); } if (result == FLB_PROCESSOR_SUCCESS) { - result = upsert_labels(metrics_context, + result = upsert_labels(out_cmt, &processor_context->upsert_labels); } if (result == FLB_PROCESSOR_SUCCESS) { - result = insert_labels(metrics_context, + result = insert_labels(out_cmt, &processor_context->insert_labels); } if (result == FLB_PROCESSOR_SUCCESS) { - result = hash_labels(metrics_context, + result = hash_labels(out_cmt, &processor_context->hash_labels); } - if (result == FLB_PROCESSOR_SUCCESS) { - result = cmt_cat(out_cmt, metrics_context); - if (result != 0) { - cmt_destroy(out_cmt); - - return FLB_PROCESSOR_FAILURE; - } - - *out_context = out_cmt; - } - if (result != FLB_PROCESSOR_SUCCESS) { return FLB_PROCESSOR_FAILURE; } + *out_context = out_cmt; return FLB_PROCESSOR_SUCCESS; }