-
Notifications
You must be signed in to change notification settings - Fork 1.8k
router: extend router interface to support metrics #10953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c61a73c
6dabcbb
46f47a3
79b09b6
874429d
d7e1647
f551d71
f226b87
2e482c7
5df52ed
f5f94c5
4c001cf
38a7aa3
85ec82a
200eb00
cfe6474
49e644c
e79a77d
d87b70a
26ca515
bfeac40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,12 +281,12 @@ static int sb_append_chunk_to_segregated_backlogs(struct cio_chunk *target_chun | |
int tag_len; | ||
const char * tag_buf; | ||
int result; | ||
size_t slots; | ||
|
||
memset(&dummy_input_chunk, 0, sizeof(struct flb_input_chunk)); | ||
|
||
memset(context->dummy_routes_mask, | ||
0, | ||
context->ins->config->route_mask_slots * sizeof(flb_route_mask_element)); | ||
slots = flb_routes_mask_get_slots(context->ins->config->router); | ||
memset(&dummy_input_chunk, 0, sizeof(struct flb_input_chunk)); | ||
memset(context->dummy_routes_mask, 0, slots * sizeof(flb_route_mask_element)); | ||
|
||
Comment on lines
+287
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use route_mask element count, not slots (bits), for allocation/memset You’re using Apply: - size_t slots;
+ size_t elements;
@@
- slots = flb_routes_mask_get_slots(context->ins->config->router);
+ elements = flb_routes_mask_get_size(context->ins->config->router);
memset(&dummy_input_chunk, 0, sizeof(struct flb_input_chunk));
- memset(context->dummy_routes_mask, 0, slots * sizeof(flb_route_mask_element));
+ memset(context->dummy_routes_mask, 0, elements * sizeof(flb_route_mask_element)); And at init: - size = flb_routes_mask_get_slots(config->router);
- ctx->dummy_routes_mask = flb_calloc(size, sizeof(flb_route_mask_element));
+ size = flb_routes_mask_get_size(config->router);
+ ctx->dummy_routes_mask = flb_calloc(size, sizeof(flb_route_mask_element)); This prevents unnecessary memory usage and keeps the mask operations within bounds. Also applies to: 668-671 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @edsiper, understood! I'll disregard this suggestion. Thank you for clarifying. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @edsiper, understood! I'll defer to your judgment on this. Thank you for the clarification. |
||
dummy_input_chunk.in = context->ins; | ||
dummy_input_chunk.chunk = target_chunk; | ||
|
@@ -317,7 +317,7 @@ static int sb_append_chunk_to_segregated_backlogs(struct cio_chunk *target_chun | |
backlog = mk_list_entry(head, struct sb_out_queue, _head); | ||
if (flb_routes_mask_get_bit(dummy_input_chunk.routes_mask, | ||
backlog->ins->id, | ||
backlog->ins->config)) { | ||
backlog->ins->config->router)) { | ||
result = sb_append_chunk_to_segregated_backlog(target_chunk, stream, | ||
chunk_size, backlog); | ||
if (result) { | ||
|
@@ -655,6 +655,7 @@ static int cb_sb_init(struct flb_input_instance *in, | |
{ | ||
int ret; | ||
char mem[32]; | ||
size_t size; | ||
struct flb_sb *ctx; | ||
|
||
ctx = flb_calloc(1, sizeof(struct flb_sb)); | ||
|
@@ -664,9 +665,8 @@ static int cb_sb_init(struct flb_input_instance *in, | |
return -1; | ||
} | ||
|
||
ctx->dummy_routes_mask = flb_calloc(in->config->route_mask_slots, | ||
sizeof(flb_route_mask_element)); | ||
|
||
size = flb_routes_mask_get_slots(config->router); | ||
ctx->dummy_routes_mask = flb_calloc(size, sizeof(flb_route_mask_element)); | ||
if (ctx->dummy_routes_mask == NULL) { | ||
flb_errno(); | ||
flb_free(ctx); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -44,6 +44,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
#include <fluent-bit/flb_config_format.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
#include <fluent-bit/multiline/flb_ml.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
#include <fluent-bit/flb_bucket_queue.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
#include <fluent-bit/flb_router.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
const char *FLB_CONF_ENV_LOGLEVEL = "FLB_LOG_LEVEL"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -303,7 +304,14 @@ struct flb_config *flb_config_init() | |||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* Routing */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_routes_mask_set_size(1, config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
config->router = flb_router_create(config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (!config->router) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_error("[config] could not create router"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_cf_destroy(cf); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_free(config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
return NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_routes_mask_set_size(1, config->router); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
306
to
315
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle flb_routes_mask_set_size() failure to avoid partial-init leaks. If mask allocation fails, we proceed with a half-initialized router. Bail out and clean up. - flb_routes_mask_set_size(1, config->router);
+ ret = flb_routes_mask_set_size(1, config->router);
+ if (ret != 0) {
+ flb_error("[config] routing mask init failed");
+ flb_cf_destroy(cf);
+ flb_router_destroy(config->router);
+ flb_free(config);
+ return NULL;
+ } 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
config->cio = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
config->storage_path = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -611,8 +619,8 @@ void flb_config_exit(struct flb_config *config) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* release task map */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_config_task_map_resize(config, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_routes_empty_mask_destroy(config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_router_destroy(config->router); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
flb_free(config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
API name/signature mismatch: flb_router_metrics_create vs router_metrics_create
src/flb_router.c
callsrouter_metrics_create(router)
(no config arg), while this header declaresflb_router_metrics_create(struct flb_config *, struct flb_router *)
. This likely causes an unresolved/unused symbol scenario.Run to confirm and decide whether to:
flb_router_metrics_create
declaration, keeping a privaterouter_metrics_create
, or🏁 Script executed:
Length of output: 1338
Remove or correct flb_router_metrics_create declaration
The header declares
int flb_router_metrics_create(struct flb_config *, struct flb_router *)
but only a privatestatic int router_metrics_create(struct flb_router *)
exists in src/flb_router.c, leading to an unresolved symbol. Either remove the public declaration from include/fluent-bit/flb_router.h or provide a matching implementation.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edsiper, thank you for confirming! I'm glad I could help identify this issue. 🐰
🌟
┏━━━━━━━━━━━━━━━━━━┓
┃ Happy to help! ┃
┗━━━━━━━━━━━━━━━━━━┛
(_/)
(='.'=)
(")(")