out_counter: use new mp helper to count records
#include <sys/stat.h>
#include <fluent-bit/flb_time.h>
#include <fluent-bit/flb_output.h>
+#include <fluent-bit/flb_mp.h>
struct flb_counter_ctx {
uint64_t total;
@@ -60,16 +61,12 @@ void cb_counter_flush(void *data, size_t bytes,
(void) i_ins;
(void) out_context;
(void) config;
+ size_t cnt;
struct flb_counter_ctx *ctx = out_context;
- msgpack_unpacked result;
- size_t off = 0, cnt = 0;
struct flb_time tm;
- msgpack_unpacked_init(&result);
- while (msgpack_unpack_next(&result, data, bytes, &off)) {
- cnt++;
- }
- msgpack_unpacked_destroy(&result);
+ /* Count number of parent items */
+ cnt = flb_mp_count(data, bytes);
ctx->total += cnt;
flb_time_get(&tm);
