Skip to content

Commit

Permalink
out_stdout: consume entire metrics type of buffers (#9118)
Browse files Browse the repository at this point in the history
Like as ctraces events, there is possibilities to have multiple
concatenated cmetrics buffers case.
For instance, calling flb_input_metrics_append more than one per a
cycle, msgpack payload of cmetrics have multiply concatenated contexts
of cmetrics.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 authored Jul 24, 2024
1 parent 574a69a commit 1a571a9
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions plugins/out_stdout/stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,32 @@ static void print_metrics_text(struct flb_output_instance *ins,
size_t off = 0;
cfl_sds_t text;
struct cmt *cmt = NULL;
int ok = CMT_DECODE_MSGPACK_SUCCESS;

/* get cmetrics context */
ret = cmt_decode_msgpack_create(&cmt, (char *) data, bytes, &off);
if (ret != 0) {
flb_plg_error(ins, "could not process metrics payload");
return;
}
while((ret = cmt_decode_msgpack_create(&cmt,
(char *) data,
bytes, &off)) == ok) {
if (ret != 0) {
flb_plg_error(ins, "could not process metrics payload");
return;
}

/* convert to text representation */
text = cmt_encode_text_create(cmt);
/* convert to text representation */
text = cmt_encode_text_create(cmt);

/* destroy cmt context */
cmt_destroy(cmt);
/* destroy cmt context */
cmt_destroy(cmt);

printf("%s", text);
fflush(stdout);
printf("%s", text);
fflush(stdout);

cmt_encode_text_destroy(text);
}

cmt_encode_text_destroy(text);
if (ret != ok) {
flb_plg_debug(ins, "cmt decode msgpack returned : %d", ret);
}
}
#endif

Expand Down

0 comments on commit 1a571a9

Please sign in to comment.