Skip to content

Commit

Permalink
output: Fix handling of metrics in output processor
Browse files Browse the repository at this point in the history
This patch passes an cmt_out_context pointer so that output processors
can modify metrics.

Signed-off-by: Thiago Padilha <[email protected]>
  • Loading branch information
tchrono authored and edsiper committed May 23, 2024
1 parent 7ac7d50 commit dc3718e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions include/fluent-bit/flb_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ struct flb_output_flush *flb_output_flush_create(struct flb_task *task,
struct cmt *metrics_context;
struct ctrace *trace_context;
size_t chunk_offset;
struct cmt *cmt_out_context = NULL;

/* Custom output coroutine info */
out_flush = (struct flb_output_flush *) flb_calloc(1, sizeof(struct flb_output_flush));
Expand Down Expand Up @@ -715,13 +716,25 @@ struct flb_output_flush *flb_output_flush_create(struct flb_task *task,
flb_sds_len(evc->tag),
(char *) metrics_context,
0,
NULL,
(void **)&cmt_out_context,
NULL);

if (ret == 0) {
ret = cmt_encode_msgpack_create(metrics_context,
&serialized_context_buffer,
&serialized_context_size);
if (cmt_out_context != NULL) {
ret = cmt_encode_msgpack_create(cmt_out_context,
&serialized_context_buffer,
&serialized_context_size);

if (cmt_out_context != metrics_context) {
cmt_destroy(cmt_out_context);
}

}
else {
ret = cmt_encode_msgpack_create(metrics_context,
&serialized_context_buffer,
&serialized_context_size);
}

cmt_destroy(metrics_context);

Expand Down

0 comments on commit dc3718e

Please sign in to comment.