out_kinesis_streams: add compression_level option - #12317
Draft
ivan-bushmarinov wants to merge 3 commits into
Draft
out_kinesis_streams: add compression_level option#12317ivan-bushmarinov wants to merge 3 commits into
ivan-bushmarinov wants to merge 3 commits into
Conversation
Expose the zstd compression level as a parameter. The existing flb_zstd_compress() keeps its historical hardcoded level (1) by delegating to the new function, so current callers are unchanged. Levels are validated against ZSTD_minCLevel()/ZSTD_maxCLevel(). Signed-off-by: Ivan Bushmarinov <ivan.bushmarinov@perplexity.ai>
Add flb_aws_compression_compress_level() and flb_aws_compression_b64_truncate_compress_level() taking an explicit compression level, with FLB_AWS_COMPRESS_LEVEL_DEFAULT preserving each codec's built-in default. The existing entry points delegate with the default sentinel, so behavior is unchanged for current callers. A non-default level is honored for zstd; codecs without a tunable level fall back to their default with a warning. Covered by a roundtrip internal test. Signed-off-by: Ivan Bushmarinov <ivan.bushmarinov@perplexity.ai>
Allow tuning the record compression level (honored for zstd; other codecs keep their built-in default). The plugin previously compressed zstd at a hardcoded level 1 with no way to trade CPU for ratio, which matters for high-volume streams where per-record compression is the dominant cost lever. Defaults preserve existing behavior; setting compression_level without compression is a configuration error. Signed-off-by: Ivan Bushmarinov <ivan.bushmarinov@perplexity.ai>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi fluent-bit maintainers, here at Perplexity we emit records of significant size (100s of K) via fluent-bit and would benefit from being able to set higher compression levels for zstd.
— Ivan Bushmarinov
Full disclosure: the note above is from the human submitter; the implementation and the rest of this description were written by an LLM under human direction and review (Anthropic Claude Fable 5, model id
claude-fable-5, via Claude Code 2.1.226).What this adds
A
compression_leveloption onout_kinesis_streams. Today the plugin compresses each record at zstd's fastest setting —flb_zstd_compress()hardcodesZSTD_compress(..., 1)— with no way to trade CPU for ratio. For high-volume streams of large JSON records, higher zstd levels meaningfully reduce Kinesis throughput costs.Implementation
Three commits, each preserving existing behavior exactly when the option is unset:
zstd: add flb_zstd_compress_level()— level-parameterized variant, validated againstZSTD_minCLevel()/ZSTD_maxCLevel();flb_zstd_compress()delegates with its historical level 1.aws compress: support explicit compression level—flb_aws_compression_compress_level()/flb_aws_compression_b64_truncate_compress_level()with aFLB_AWS_COMPRESS_LEVEL_DEFAULTsentinel; the compression-options table gains an optional level-aware function pointer (populated for zstd; gzip/snappy fall back to their built-in defaults with a warning). Existing entry points delegate with the sentinel — no call-site changes needed in other plugins (out_kinesis_firehose,out_s3are untouched and can adopt the option later).out_kinesis_streams: add compression_level option— config map entry + validation (compression_levelwithoutcompressionis a configuration error), threaded through both the per-record and aggregation send paths.Testing
test_compression_zstd_level(roundtrip at an explicit level, sentinel-equals-default, oversized-level rejection, non-tunable-codec fallback); fullflb-it-aws_compresssuite passes locally (macOS arm64, Release).flb-plugin-out_kinesis_streamscompiles clean.Happy to extend the option to
out_kinesis_firehose/out_s3in this PR or a follow-up if preferred, and to add the docs-repo page update.Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.