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 <[email protected]>
  • Loading branch information
cosmo0920 committed May 14, 2024
1 parent ce7aafa commit 2f9053b
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions plugins/processor_labels/labels.c
Original file line number Diff line number Diff line change
Expand Up @@ -1520,32 +1520,26 @@ static int insert_labels(struct cmt *metrics_context,
cfl_list_foreach(iterator, labels) {
pair = cfl_list_entry(iterator, struct cfl_kv, _head);

result = metrics_context_contains_dynamic_label(metrics_context,
pair->key);
result = metrics_context_insert_dynamic_label(metrics_context,
pair->key,
pair->val);

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

result = metrics_context_contains_static_label(metrics_context,
pair->key);

if (result == FLB_TRUE) {
result = metrics_context_insert_dynamic_label(metrics_context,
pair->key,
pair->val);
result = metrics_context_insert_static_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);

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

return FLB_PROCESSOR_SUCCESS;
Expand Down

0 comments on commit 2f9053b

Please sign in to comment.