Skip to content

Commit

Permalink
processor_labels: Remove a needless existence check for insert operation
Browse files Browse the repository at this point in the history
Insert implies that adding new key-value pairs of labels.
However, we did put the existence check for the keys of labels.
This shouldn't be effective for such operation.

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
  • Loading branch information
cosmo0920 authored and edsiper committed May 15, 2024
1 parent abb3b06 commit bf04226
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions plugins/processor_labels/labels.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,26 +1524,27 @@ static int insert_labels(struct cmt *metrics_context,
pair->key);

if (result == FLB_TRUE) {
result = metrics_context_insert_dynamic_label(metrics_context,
pair->key,
pair->val);
continue;
}

if (result == FLB_FALSE) {
return FLB_FALSE;
}
result = metrics_context_insert_dynamic_label(metrics_context,
pair->key,
pair->val);

if (result == FLB_FALSE) {
return FLB_FALSE;
}
else {
result = metrics_context_contains_static_label(metrics_context,
pair->key);

if (result == FLB_FALSE) {
result = metrics_context_insert_static_label(metrics_context,
pair->key,
pair->val);
result = metrics_context_contains_static_label(metrics_context,
pair->key);

if (result == FLB_FALSE) {
return FLB_FALSE;
}
if (result == FLB_TRUE) {
result = metrics_context_insert_static_label(metrics_context,
pair->key,
pair->val);

if (result == FLB_FALSE) {
return FLB_FALSE;
}
}
}
Expand Down

0 comments on commit bf04226

Please sign in to comment.