conditionals: resolve TAG record accessor in processor and filter conditions#12090
Open
zshuang0316 wants to merge 5 commits into
Open
conditionals: resolve TAG record accessor in processor and filter conditions#12090zshuang0316 wants to merge 5 commits into
zshuang0316 wants to merge 5 commits into
Conversation
The record accessor already parses TAG / TAG[n], but evaluate_rule() passed NULL for the tag to flb_cfl_ra_translate(), so rules referencing $TAG never resolved and silently failed to match. Add tag/tag_len parameters to flb_condition_evaluate() and flb_condition_evaluate_ex() and forward them to the record accessor. Carry the chunk tag on struct flb_mp_chunk_cobj so callers can supply it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: zshuang0316 <zshuang0316@163.com>
flb_mp_chunk_cobj_record_next() now forwards chunk_cobj->tag/tag_len to flb_condition_evaluate() so $TAG rules resolve during record iteration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: zshuang0316 <zshuang0316@163.com>
Set chunk_cobj->tag/tag_len around the processor callback and thread the tag into evaluate_condition_for_log_event(), so processor and filter conditions can match on $TAG. The tag is cleared after processing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: zshuang0316 <zshuang0316@163.com>
The router matches by tag natively, so pass NULL/0 for the new tag arguments of flb_condition_evaluate_ex(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: zshuang0316 <zshuang0316@163.com>
Update the existing call sites for the new tag arguments and add positive and negative coverage for $TAG conditions (exact match, regex, a non-matching tag, and the no-tag case). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: zshuang0316 <zshuang0316@163.com>
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
e925bf2 to
6142006
Compare
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
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.
Summary
Condition rules used by processors and filters could not match on the record
tag. The record accessor already parses
$TAG/$TAG[n], but the conditionevaluator called
flb_cfl_ra_translate()with aNULLtag, so any rulereferencing
$TAGsilently never resolved.This PR threads the chunk tag through the condition-evaluation path:
flb_condition_evaluate()/flb_condition_evaluate_ex()andevaluate_rule()gain
tag/tag_lenarguments and forward them toflb_cfl_ra_translate().struct flb_mp_chunk_cobjcarries the chunktag/tag_len;flb_processorsets them around the processor callback and clears them afterwards.
flb_mp) and the filter path pass the chunk tag; therouter passes
NULLsince it already routes by tag natively.This enables conditions such as:
so a processor or filter can select records by tag.
The change is split into per-subsystem commits (
conditionals:,mp:,processor:,router_condition:,tests:) to satisfy the commit-prefixconvention; the tree builds as a whole.
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
Unit coverage is added in
tests/internal/conditionals.c(tag_accessor):exact-match, regex, non-matching tag, and the no-tag case. I'll follow up with
runtime debug/Valgrind logs.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
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.