Skip to content

Commit

Permalink
filter: update total_records outside of ifdef
Browse files Browse the repository at this point in the history
Similarly to other spots, total_records is expected to be set in a few
plugins outside of FLB_HAVE_METRICS definitions. This makes it so when
this value is set on filter, it happens outside of the definition so
that filters that change the size of total_records will still have the
values reflected.

Signed-off-by: braydonk <[email protected]>
  • Loading branch information
braydonk committed Nov 28, 2023
1 parent 70c03b7 commit eb82b97
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/flb_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ void flb_filter_do(struct flb_input_chunk *ic,
#ifdef FLB_HAVE_METRICS
/* timestamp */
ts = cfl_time_now();
#endif

/* Count number of incoming records */
in_records = ic->added_records;
pre_records = ic->total_records - in_records;
#endif

/* Iterate filters */
mk_list_foreach(head, &config->filters) {
Expand Down Expand Up @@ -201,10 +201,9 @@ void flb_filter_do(struct flb_input_chunk *ic,
}
#endif /* FLB_HAVE_CHUNK_TRACE */


#ifdef FLB_HAVE_METRICS
ic->total_records = pre_records;

#ifdef FLB_HAVE_METRICS
/* cmetrics */
cmt_counter_add(f_ins->cmt_drop_records, ts, in_records,
1, (char *[]) {name});
Expand All @@ -216,8 +215,9 @@ void flb_filter_do(struct flb_input_chunk *ic,
break;
}
else {
#ifdef FLB_HAVE_METRICS
out_records = flb_mp_count(out_buf, out_size);

#ifdef FLB_HAVE_METRICS
if (out_records > in_records) {
diff = (out_records - in_records);

Expand All @@ -240,11 +240,11 @@ void flb_filter_do(struct flb_input_chunk *ic,
flb_metrics_sum(FLB_METRIC_N_DROPPED,
diff, f_ins->metrics);
}
#endif

/* set number of records in new chunk */
in_records = out_records;
ic->total_records = pre_records + in_records;
#endif
}

#ifdef FLB_HAVE_CHUNK_TRACE
Expand Down

0 comments on commit eb82b97

Please sign in to comment.