Skip to content

Instantly share code, notes, and snippets.

@drbugfinder-work
Created February 9, 2024 23:08
Show Gist options
  • Save drbugfinder-work/f5eb5bf175e9a164cf27b954ba41b188 to your computer and use it in GitHub Desktop.
Save drbugfinder-work/f5eb5bf175e9a164cf27b954ba41b188 to your computer and use it in GitHub Desktop.
in_emitter_debug_output.diff
diff --git a/plugins/in_emitter/emitter.c b/plugins/in_emitter/emitter.c
index 62886d1..aded98b 100644
--- a/plugins/in_emitter/emitter.c
+++ b/plugins/in_emitter/emitter.c
@@ -138,8 +138,10 @@ int in_emitter_add_record(const char *tag, int tag_len,
(void *) &temporary_chunk,
sizeof(struct em_chunk));
}
-
+ flb_plg_debug(ctx->ins, "did not use ring-buffer");
/* Check if any target chunk already exists */
+ int size = mk_list_size(&ctx->chunks);
+ flb_plg_debug(ctx->ins, "Number of existing chunks: %d", size);
mk_list_foreach(head, &ctx->chunks) {
ec = mk_list_entry(head, struct em_chunk, _head);
if (flb_sds_cmp(ec->tag, tag, tag_len) != 0) {
@@ -148,6 +150,11 @@ int in_emitter_add_record(const char *tag, int tag_len,
}
break;
}
+ if (!ec) {
+ flb_plg_debug(ctx->ins, "no candidate chunk found, create a new one for tag: %s", tag);
+ } else {
+ flb_plg_debug(ctx->ins, "candidate chunk found for tag: %s", tag);
+ }
/* No candidate chunk found, so create a new one */
if (!ec) {
@@ -156,12 +163,13 @@ int in_emitter_add_record(const char *tag, int tag_len,
flb_plg_error(ctx->ins, "cannot create new chunk for tag: %s",
tag);
return -1;
+ } else {
+ flb_plg_debug(ctx->ins, "new chunk created for tag: %s", tag);
}
}
/* Append raw msgpack data */
msgpack_sbuffer_write(&ec->mp_sbuf, buf_data, buf_size);
-
return do_in_emitter_add_record(ec, in);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment