Skip to content

Commit 3ce15c6

Browse files
srini38edsiper
authored andcommitted
out_stdout: Fix incomplete printing of traces
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]>
1 parent e6c03aa commit 3ce15c6

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

plugins/out_stdout/stdout.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,26 @@ static void print_traces_text(struct flb_output_instance *ins,
135135
size_t off = 0;
136136
cfl_sds_t text;
137137
struct ctrace *ctr = NULL;
138+
int ok = CTR_DECODE_MSGPACK_SUCCESS;
138139

139-
/* get cmetrics context */
140-
ret = ctr_decode_msgpack_create(&ctr, (char *) data, bytes, &off);
141-
if (ret != 0) {
142-
flb_plg_error(ins, "could not process traces payload (ret=%i)", ret);
143-
return;
144-
}
145-
146-
/* convert to text representation */
147-
text = ctr_encode_text_create(ctr);
140+
/* Decode each ctrace context */
141+
while ((ret = ctr_decode_msgpack_create(&ctr,
142+
(char *) data,
143+
bytes, &off)) == ok) {
144+
/* convert to text representation */
145+
text = ctr_encode_text_create(ctr);
148146

149-
/* destroy cmt context */
150-
ctr_destroy(ctr);
147+
/* destroy ctr context */
148+
ctr_destroy(ctr);
151149

152-
printf("%s", text);
153-
fflush(stdout);
150+
printf("%s", text);
151+
fflush(stdout);
154152

155-
ctr_encode_text_destroy(text);
153+
ctr_encode_text_destroy(text);
154+
}
155+
if (ret != ok) {
156+
flb_plg_debug(ins, "ctr decode msgpack returned : %d", ret);
157+
}
156158
}
157159

158160
static void cb_stdout_flush(struct flb_event_chunk *event_chunk,

0 commit comments

Comments
 (0)