Skip to content

filter_log_to_metrics: fix initialization and exception cleanup#11420

Merged
edsiper merged 3 commits intomasterfrom
processor-log_to_metrics
Feb 4, 2026
Merged

filter_log_to_metrics: fix initialization and exception cleanup#11420
edsiper merged 3 commits intomasterfrom
processor-log_to_metrics

Conversation

@edsiper
Copy link
Member

@edsiper edsiper commented Feb 2, 2026

  • processor: fix handling of numeric values in config map
  • filter: validate NULL values in properties
  • filter_log_to_metrics: fix initialization and exception cleanup

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.

Summary by CodeRabbit

  • New Features

    • Extended processor unit configuration to support numeric array elements (integers, unsigned integers, and floating-point numbers) alongside existing string support.
  • Bug Fixes

    • Added defensive validation to prevent crashes from null values in property operations.
    • Improved error handling and lifecycle management in the metrics logging pipeline for better stability.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@edsiper edsiper requested a review from cosmo0920 as a code owner February 2, 2026 21:52
@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Refactors error handling lifecycle in the log_to_metrics plugin by consolidating context cleanup paths, adds NULL-safety checks in filter property setting, and extends processor unit property handling to accept numeric array elements with automatic string conversion.

Changes

Cohort / File(s) Summary
Log-to-Metrics Plugin Lifecycle
plugins/filter_log_to_metrics/log_to_metrics.c
Restructures context initialization and cleanup flow: removes redundant intermediate destroy calls on error paths, sets context early via flb_filter_set_context, adds NULL guard in exit callback, and initializes ctx->rules earlier in initialization sequence.
Filter Property Setting
src/flb_filter.c
Adds defensive NULL check for value parameter in flb_filter_set_property before string translation, returning error code if NULL is passed.
Processor Array Element Type Support
src/flb_processor.c
Extends processor unit property array handling to accept numeric types (int, uint, double) alongside strings; converts numeric elements to strings via snprintf for property setting, with error logging for unsupported types.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

backport to v4.0.x

Suggested reviewers

  • koleini
  • fujimotos

Poem

A filter's life, once tangled, now clean,
NULL guards stand watch where crashes had been,
Numbers transform to strings in a dance,
Lifecycle flows with improved stance—
Defensive and tidy, our code takes its chance! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'filter_log_to_metrics: fix initialization and exception cleanup' directly and clearly describes the main change in the primary modified file (plugins/filter_log_to_metrics/log_to_metrics.c), focusing on the refactored error handling and lifecycle management.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch processor-log_to_metrics

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 839c07c993

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@edsiper edsiper added this to the Fluent Bit v5.0 milestone Feb 4, 2026
@edsiper edsiper merged commit 06bcb8a into master Feb 4, 2026
54 of 92 checks passed
@edsiper edsiper deleted the processor-log_to_metrics branch February 4, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant