diff --git a/plugins/out_stdout/stdout.c b/plugins/out_stdout/stdout.c index 2d6bff59856..6183460a0db 100644 --- a/plugins/out_stdout/stdout.c +++ b/plugins/out_stdout/stdout.c @@ -135,24 +135,26 @@ static void print_traces_text(struct flb_output_instance *ins, size_t off = 0; cfl_sds_t text; struct ctrace *ctr = NULL; + int ok = CTR_DECODE_MSGPACK_SUCCESS; - /* get cmetrics context */ - ret = ctr_decode_msgpack_create(&ctr, (char *) data, bytes, &off); - if (ret != 0) { - flb_plg_error(ins, "could not process traces payload (ret=%i)", ret); - return; - } - - /* convert to text representation */ - text = ctr_encode_text_create(ctr); + /* Decode each ctrace context */ + while ((ret = ctr_decode_msgpack_create(&ctr, + (char *) data, + bytes, &off)) == ok) { + /* convert to text representation */ + text = ctr_encode_text_create(ctr); - /* destroy cmt context */ - ctr_destroy(ctr); + /* destroy ctr context */ + ctr_destroy(ctr); - printf("%s", text); - fflush(stdout); + printf("%s", text); + fflush(stdout); - ctr_encode_text_destroy(text); + ctr_encode_text_destroy(text); + } + if (ret != ok) { + flb_plg_debug(ins, "ctr decode msgpack returned : %d", ret); + } } static void cb_stdout_flush(struct flb_event_chunk *event_chunk,