Skip to content

Commit

Permalink
out_stdout: Fix incomplete printing of traces
Browse files Browse the repository at this point in the history
This patch fixes print_traces_text() function to print all ctrace contexts

the patch has been tested with opentelemetry-cpp-1.12.0/example_otlp_http
http://localhost:4318/v1/traces DEBUG=yes bin, fluent-bit 2.2.0 and ctrace fix
(fluent/ctraces#46)

Signed-off-by: Srinivasan J <[email protected]>
  • Loading branch information
srini38 authored and edsiper committed Dec 20, 2023
1 parent e6c03aa commit 3ce15c6
Showing 1 changed file with 16 additions and 14 deletions.
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

0 comments on commit 3ce15c6

Please sign in to comment.