Skip to content

Commit d366fca

Browse files
committed
filter_multiline: Process truncated metrics always
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 20c7695 commit d366fca

File tree

1 file changed

+8
-13
lines changed
  • plugins/filter_multiline

1 file changed

+8
-13
lines changed

plugins/filter_multiline/ml.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -369,18 +369,23 @@ static int cb_ml_init(struct flb_filter_instance *ins,
369369
"fluentbit", "filter", "emit_records_total",
370370
"Total number of emitted records",
371371
1, (char *[]) {"name"});
372+
373+
/* OLD api */
374+
flb_metrics_add(FLB_MULTILINE_METRIC_EMITTED,
375+
"emit_records", ctx->ins->metrics);
376+
#endif
377+
}
378+
/* Truncated metrics always should be existing. */
379+
#ifdef FLB_HAVE_METRICS
372380
ctx->cmt_truncated = cmt_counter_create(ins->cmt,
373381
"fluentbit", "filter", "emit_truncated_total",
374382
"Total number of truncated occurence of multiline",
375383
1, (char *[]) {"name"});
376384

377385
/* OLD api */
378-
flb_metrics_add(FLB_MULTILINE_METRIC_EMITTED,
379-
"emit_records", ctx->ins->metrics);
380386
flb_metrics_add(FLB_MULTILINE_METRIC_TRUNCATED,
381387
"emit_truncated", ctx->ins->metrics);
382388
#endif
383-
}
384389

385390
mk_list_init(&ctx->ml_streams);
386391
mk_list_init(&ctx->split_message_packers);
@@ -846,16 +851,6 @@ static int cb_ml_filter(const void *data, size_t bytes,
846851
flb_plg_debug(ctx->ins,
847852
"could not append object from tag: %s", tag);
848853
}
849-
else if (ret == FLB_MULTILINE_OK) {
850-
#ifdef FLB_HAVE_METRICS
851-
name = (char *) flb_filter_name(ctx->ins);
852-
ts = cfl_time_now();
853-
cmt_counter_inc(ctx->cmt_emitted, ts, 1, (char *[]) {name});
854-
855-
/* old api */
856-
flb_metrics_sum(FLB_MULTILINE_METRIC_EMITTED, 1, ctx->ins->metrics);
857-
#endif
858-
}
859854
}
860855

861856
flb_log_event_decoder_destroy(&decoder);

0 commit comments

Comments
 (0)