-
Notifications
You must be signed in to change notification settings - Fork 6
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
sds: add cfl_sds_snprintf #33
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Takahiro Yamashita <[email protected]>
If I understand that conversation correctly, the reason why we have If that's the case, then what we should do is take this opportunity to improve the clarity of the situation by renaming the existing Of course in this case we would have to check all of our code to issue the appropriate updates but as far as I can see the only code that relies on that behavior is the ctraces text encoder which would be trivial to update (and not critical by any means). This is not just me being pedantic but rather making the most of this opportunity to make our code clearer both when it comes to what the naming conveys and by minimizing code duplication. |
Yes it is the reason.
I don't know how many codes will be affected. In my understanding, fluent-bit will replace to call cfl_sds_* API in the future, is it right ?
|
It's true that a lot of code uses |
How about creating another PR to rename This patch is to adding I think |
I would rather hold off and make all the changes at once since otherwise we'd be opening the window for the proliferation of the use of something that shouldn't be used otherwise. |
In my understanding, the function prototype is not changed and it means breaking change of It is hard for me to guarantee proper renaming. |
We could guarantee it by searching through the code bases that use the library (which is a glorified grep) but if that's not possible then we need to drop the old name and choose two new names, test it and deal with whatever breaks. |
We will need this choosing when updating cfl on fluent-bit and renaming
There are 169 lines using Currently there is no test code for in_otel at v2.1.4. For backward compatibility, I recommend keeping cfl_sds_t cfl_sds_printf(cfl_sds_t *sds, const char *fmt, ...)
{
#ifdef DEBUG // or something
printf("%s this function is obsolete. Please call cfl_sds_cat_printf or ...\n", __FUNCTION__);
#endif
// call cfl_sds_cat_printf();
...
} |
It's easier to rip the band-aid once and mindfully pay the price than to waste this opportunity and make it harder for whomever takes on this task in the future. |
I agree with that approach. actually if we look at the original SDS library that I stole from Redis we found similar logic: https://github.com/redis/redis/blob/unstable/src/sds.c#L544 not sure about migrating old code, but definitely we should encourage best practices for new code that gets in. yes, changing this here will require some fixes in fluent bit otel plugin, but it seems pretty straightforward @nokute78 pls confirm if you can work on the requested changes. |
This patch is porting
flb_sds_snprintf
and its test code.https://github.com/fluent/fluent-bit/blob/v2.1.3/src/flb_sds.c#L477
The discussion of this function
fluent/fluent-bit#4361 (comment)