Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out_stdout: Fix incomplete printing of traces #8264

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions plugins/out_stdout/stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading