Skip to content

Conversation

@jmccormick7
Copy link

@jmccormick7 jmccormick7 commented Oct 10, 2025

This commit adds event_type to the flb_plugin_proxy_def struct. This allows for the setting of event_type to a value other than the default log only initialization.

In the flb_plugin_proxy_register function default behavior is enforced by checking for unset event_type values. When unset (a value of 0) then log behavior is defaulted. No need for incorrect value checking since this was not a set field in the past. Unset fields are set as current behavior dictates and future use cases using incorrect values can be treated as user error.

Input use case does not use event-type and is unaffected by this change.

Addresses #10995

This corresponding PR in the fluent-bit-go library enables the ability to allow Go plugins to register their event types PR 80


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:

  • [N/A] Example configuration file for the change
  • [N/A] Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found
100% tests passed, 0 tests failed out of 164

Label Time Summary:
internal    =  85.38 sec*proc (70 tests)
runtime     = 2026.55 sec*proc (83 tests)

Total Test time (real) = 2212.60 sec
==46444== 
==46444== HEAP SUMMARY:
==46444==     in use at exit: 0 bytes in 0 blocks
==46444==   total heap usage: 5,012 allocs, 5,012 frees, 54,842,164 bytes allocated
==46444== 
==46444== All heap blocks were freed -- no leaks are possible
==46444== 
==46444== For lists of detected and suppressed errors, rerun with: -s
==46444== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

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

Release Notes

  • New Features

    • Added event type support to proxy plugin definitions for enhanced plugin compatibility.
  • Tests

    • Added Go-based proxy plugin testing framework.
    • Introduced proxy logs compatibility test suite.
    • Expanded test environment configuration for Linux systems.
  • Chores

    • Updated proxy plugin registration logic.
    • Enhanced build configuration for test plugins.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2025

Walkthrough

This changeset introduces proxy plugin support for logs in Fluent Bit. It adds an event_type field to the plugin proxy definition structure, updates proxy registration logic to propagate event types, and implements comprehensive test infrastructure including a Go-based output plugin, test configuration, build scripts, and runtime shell tests.

Changes

Cohort / File(s) Summary
Plugin Proxy API
include/fluent-bit/flb_plugin_proxy.h
Added int event_type field to struct flb_plugin_proxy_def to store event type (logs/metrics/traces).
Plugin Proxy Implementation
src/flb_plugin_proxy.c
Modified flb_proxy_register_output to set output event type based on def->event_type (defaults to FLB_OUTPUT_LOGS if unset); added input plugin list registration in flb_proxy_register_input; changed flb_plugin_proxy_create to use flb_calloc instead of flb_malloc for proxy definition allocation.
Test Framework Configuration
tests/runtime_shell/CMakeLists.txt
Added Linux-specific conditional to include proxy_logs_expect.sh in shell unit tests; extended test environment to set FLB_BUILD variable alongside existing FLB_BIN.
Test Configuration & Build
tests/runtime_shell/conf/proxy_logs_test.conf, tests/runtime_shell/go_plugins/build_test_plugins.sh, tests/runtime_shell/go_plugins/go.mod
New test configuration defining Fluent Bit service, dummy input, and test output plugins; new build script ensuring Go installation, verifying CGO support, and compiling Go test plugin; new Go module declaring dependencies for fluent-bit-go and codec libraries.
Go Plugin Implementation
tests/runtime_shell/go_plugins/logs_output.go
New Go output plugin implementing logs-only support with standard lifecycle hooks (FLBPluginRegister, FLBPluginInit, FLBPluginFlushCtx, FLBPluginExit); decodes incoming records and prints them to stdout.
Runtime Test Script
tests/runtime_shell/proxy_logs_expect.sh
New shell test script executing Fluent Bit with proxy plugins, capturing output, and validating success/failure with stdout logging.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Plugin proxy header and source modifications are straightforward but require verification that event type handling logic is correct across registration flows
  • New Go plugin follows standard Fluent Bit interface patterns but implementation should be checked for correct data decoding and output handling
  • Build script contains conditional logic and fallbacks that may have cross-platform implications
  • Test configuration and shell script dependencies need validation against actual test environment setup

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 clearly summarizes the main change: adding event_type specification capability to proxy plugins, which is the primary focus of the changeset across all modified files.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0def4e6 and 8b70738.

📒 Files selected for processing (2)
  • include/fluent-bit/flb_plugin_proxy.h (1 hunks)
  • src/flb_plugin_proxy.c (2 hunks)

@cosmo0920
Copy link
Contributor

If we proceed to address this issue, we need to send another PR into here https://github.com/chronosphereio/calyptia-plugin to handle event_type as well.

@jmccormick7
Copy link
Author

jmccormick7 commented Oct 17, 2025

If we proceed to address this issue, we need to send another PR into here https://github.com/chronosphereio/calyptia-plugin to handle event_type as well.

@cosmo0920 I can open a PR in that repository tonight!

Copy link
Contributor

@cosmo0920 cosmo0920 left a comment

Choose a reason for hiding this comment

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

Looks good to me. But this PR has a possible ABI breakage of the Golang plugin interface. So, we need to test it before merging.

@jmccormick7
Copy link
Author

@cosmo0920 How would you prefer I do testing beyond the unit tests? I've done some manual testing that I can document, but is there any formalized regression testing or tests for proxy plugins?

@cosmo0920
Copy link
Contributor

cosmo0920 commented Nov 7, 2025

How about adding runtime shell test cases with precompiled Golang shared objects here?

https://github.com/fluent/fluent-bit/tree/master/tests/runtime_shell
Or, leaving as-is is still good but it tends to be delayed for reviewing without unit test addtions.

@jmccormick7
Copy link
Author

jmccormick7 commented Nov 12, 2025

@cosmo0920 I have added a runtime test that build and test a go plugin shared object. Please let me know if there are any improvements or other additions I can provide to speed up the timeline!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (5)
tests/runtime_shell/go_plugins/build_test_plugins.sh (1)

98-98: Consider using FLB_BUILD variable instead of hardcoded path.

The CMakeLists.txt now exports FLB_BUILD to the environment. Consider using $FLB_BUILD instead of constructing $BUILD_DIR to ensure consistency with the test environment.

Apply this diff:

-    CGO_ENABLED=1 GO111MODULE=on go build -buildmode=c-shared -v -ldflags="-s -w" -o $BUILD_DIR/test_logs_go.so logs_output.go
+    CGO_ENABLED=1 GO111MODULE=on go build -buildmode=c-shared -v -ldflags="-s -w" -o ${FLB_BUILD:-$BUILD_DIR}/test_logs_go.so logs_output.go
tests/runtime_shell/proxy_logs_expect.sh (2)

19-19: Use FLB_BUILD variable for consistent path construction.

The script hardcodes $FLB_ROOT/build/test_logs_go.so, but the CMakeLists.txt now provides FLB_BUILD in the environment for this purpose.

Apply this diff:

-    $FLB_BIN -e $FLB_ROOT/build/test_logs_go.so -c $FLB_RUNTIME_SHELL_CONF/proxy_logs_test.conf > "$STDOUT_OUTPUT_FILE" 2>&1 &
+    $FLB_BIN -e $FLB_BUILD/test_logs_go.so -c $FLB_RUNTIME_SHELL_CONF/proxy_logs_test.conf > "$STDOUT_OUTPUT_FILE" 2>&1 &

22-22: Replace hardcoded sleep with signal file polling.

The hardcoded sleep 3 is fragile and can cause flakiness in tests. Consider polling for the SIGNAL_FILE_PATH or checking the process output instead of using a fixed delay.

tests/runtime_shell/go_plugins/test_logs_go.h (1)

1-92: Consider excluding auto-generated CGO headers from version control.

This file is marked as auto-generated by cmd/cgo and should not be manually edited. Consider adding *.h or specifically test_logs_go.h to .gitignore in this directory, and generate it during the build process instead.

tests/runtime_shell/go_plugins/logs_output.go (1)

28-28: Consider using the timestamp from GetRecord.

The timestamp returned by GetRecord (second return value) is currently ignored. While this is acceptable for a test plugin, consider whether timestamp information would be useful for test verification.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82d792a and 74c83d1.

⛔ Files ignored due to path filters (1)
  • tests/runtime_shell/go_plugins/go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • tests/runtime_shell/CMakeLists.txt (2 hunks)
  • tests/runtime_shell/conf/proxy_logs_test.conf (1 hunks)
  • tests/runtime_shell/go_plugins/build_test_plugins.sh (1 hunks)
  • tests/runtime_shell/go_plugins/go.mod (1 hunks)
  • tests/runtime_shell/go_plugins/logs_output.go (1 hunks)
  • tests/runtime_shell/go_plugins/test_logs_go.h (1 hunks)
  • tests/runtime_shell/proxy_logs_expect.sh (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-31T12:46:11.940Z
Learnt from: ThomasDevoogdt
Repo: fluent/fluent-bit PR: 9277
File: .github/workflows/pr-compile-check.yaml:147-151
Timestamp: 2025-08-31T12:46:11.940Z
Learning: In fluent-bit CMakeLists.txt, the system library preference flags are defined as FLB_PREFER_SYSTEM_LIB_ZSTD and FLB_PREFER_SYSTEM_LIB_KAFKA with the FLB_ prefix.

Applied to files:

  • tests/runtime_shell/CMakeLists.txt
📚 Learning: 2025-08-31T12:46:11.940Z
Learnt from: ThomasDevoogdt
Repo: fluent/fluent-bit PR: 9277
File: .github/workflows/pr-compile-check.yaml:147-151
Timestamp: 2025-08-31T12:46:11.940Z
Learning: In fluent-bit, the correct CMake flag for using system librdkafka is `FLB_PREFER_SYSTEM_LIB_KAFKA=ON`.

Applied to files:

  • tests/runtime_shell/CMakeLists.txt
📚 Learning: 2025-09-04T07:28:37.083Z
Learnt from: cosmo0920
Repo: fluent/fluent-bit PR: 10832
File: src/wasm/CMakeLists.txt:112-131
Timestamp: 2025-09-04T07:28:37.083Z
Learning: In fluent-bit CMake files, the user cosmo0920 prefers treating Git as a command rather than a package, emphasizing that Git is not a pkg-config retrievable package but just a command.

Applied to files:

  • tests/runtime_shell/CMakeLists.txt
🧬 Code graph analysis (1)
tests/runtime_shell/go_plugins/test_logs_go.h (1)
tests/runtime_shell/go_plugins/logs_output.go (4)
  • FLBPluginRegister (12-15)
  • FLBPluginInit (18-20)
  • FLBPluginFlushCtx (23-39)
  • FLBPluginExit (42-44)
🔇 Additional comments (7)
tests/runtime_shell/CMakeLists.txt (2)

18-18: LGTM!

The addition of the proxy logs test to the test suite is appropriate.


31-32: LGTM!

Adding the FLB_BUILD environment variable enables tests to reference the build directory, which is useful for locating built artifacts like the test plugin shared object.

tests/runtime_shell/conf/proxy_logs_test.conf (1)

1-21: LGTM!

The test configuration is well-structured for validating the proxy logs functionality. The use of environment variables for the signal file path enables flexible test execution.

tests/runtime_shell/go_plugins/logs_output.go (2)

11-15: LGTM!

The registration function correctly delegates to the fluent-bit-go output package with appropriate plugin name and description.


22-39: LGTM!

The flush implementation correctly decodes records and outputs them to stdout for test verification. The error handling is appropriate for a test plugin.

tests/runtime_shell/go_plugins/go.mod (2)

3-3: The Go version 1.25.1 is valid and exists.

The latest stable Go release is Go 1.25.3 (released October 13, 2025), and Go 1.25.1 was released prior to that. The code's specification of go 1.25.1 is legitimate, though not the latest version available. No changes are required.

Likely an incorrect or invalid review comment.


6-6: Review comment is incorrect — PR 80 is open, not merged.

PR 80 ("Enable metric output plugins") in fluent-bit-go is currently open as of October 10, 2025 and has not been merged. Additionally, the plugin code (logs_output.go) does not use or require event_type support. The current dependency version is appropriate for the code's functionality.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@cosmo0920 cosmo0920 left a comment

Choose a reason for hiding this comment

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

The added testing mechanism is really good. We need to clarify this mechanism on Linux only.
So, we need further modifications.

@cosmo0920
Copy link
Contributor

Plus, this PR still uses outdated base branch. So, could you rebase off the current master?
No left device errors should be gone after rebasing off.

This commit adds event_type to the flb_plugin_proxy_def struct. This allows for the setting
of event_type to a value other than the default log only initialization.

In the flb_plugin_proxy_register function default behaviour is enforced by checking for unset event_type vlaues.
When unset (a value of 0) then log behaviour is defaulted. No need for incorrect value checking since this
was not a set field in the past. Unset fields are set as current behavior dicates and future usecases using incorrect values can be treated as user error.

Input use case does not use event-type and is unaffected by this change.

Signed-off-by: jmccormick7 <jcm258@case.edu>
… malloc

Changing intialization to use calloc instead of malloc so that emtpy fields are 0 initialized.
Specifically for the event_type addition.

Signed-off-by: jmccormick7 <jcm258@case.edu>
This commit adds a runtime shell test for the go plugin interface.
A dummy go output plugin is added to the directories, and a test that builds
the plugin shared object and then tests that it works and writes the output.
This test ensures that the go proxy interface is working as expected.

This was tested in the devcontainer using ctest.

Signed-off-by: jmccormick7 <jcm258@case.edu>
Signed-off-by: jmccormick7 <jcm258@case.edu>
@jmccormick7 jmccormick7 force-pushed the enable-metric-proxy-plugins branch from 6800215 to ba352c6 Compare November 21, 2025 17:45
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/runtime_shell/conf/proxy_logs_test.conf (1)

1-21: Config looks correct for the intended runtime-shell proxy logs test

SERVICE, dummy INPUT, and dual OUTPUT setup all look valid and aligned with the described test: three dummy records tagged test.logs are routed both to the Go proxy output (test_logs_go) and to a file sink controlled via ${SIGNAL_FILE_PATH}. Flush/Grace settings are reasonable for a fast test run, and mkdir on helps avoid path issues.

If you ever see test runtime bloat or want to minimize emitted records, you could optionally reduce Samples from 3 to 1, but it’s not necessary given how small this test is.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6800215 and ba352c6.

⛔ Files ignored due to path filters (1)
  • tests/runtime_shell/go_plugins/go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • include/fluent-bit/flb_plugin_proxy.h (1 hunks)
  • src/flb_plugin_proxy.c (3 hunks)
  • tests/runtime_shell/CMakeLists.txt (2 hunks)
  • tests/runtime_shell/conf/proxy_logs_test.conf (1 hunks)
  • tests/runtime_shell/go_plugins/build_test_plugins.sh (1 hunks)
  • tests/runtime_shell/go_plugins/go.mod (1 hunks)
  • tests/runtime_shell/go_plugins/logs_output.go (1 hunks)
  • tests/runtime_shell/go_plugins/test_logs_go.h (1 hunks)
  • tests/runtime_shell/proxy_logs_expect.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • include/fluent-bit/flb_plugin_proxy.h
  • tests/runtime_shell/CMakeLists.txt
  • src/flb_plugin_proxy.c
  • tests/runtime_shell/go_plugins/go.mod
  • tests/runtime_shell/go_plugins/build_test_plugins.sh
  • tests/runtime_shell/proxy_logs_expect.sh
  • tests/runtime_shell/go_plugins/logs_output.go
  • tests/runtime_shell/go_plugins/test_logs_go.h

This commit makes the go proxy a test that only runs on Linux
using the CMAKE_SYSTEM_NAME. It also removes an autogenerated
header file from the go compile that should not have been commited.

Signed-off-by: jmccormick7 <jcm258@case.edu>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba352c6 and e08bf8e.

📒 Files selected for processing (1)
  • tests/runtime_shell/CMakeLists.txt (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-31T12:46:11.940Z
Learnt from: ThomasDevoogdt
Repo: fluent/fluent-bit PR: 9277
File: .github/workflows/pr-compile-check.yaml:147-151
Timestamp: 2025-08-31T12:46:11.940Z
Learning: In fluent-bit CMakeLists.txt, the system library preference flags are defined as FLB_PREFER_SYSTEM_LIB_ZSTD and FLB_PREFER_SYSTEM_LIB_KAFKA with the FLB_ prefix.

Applied to files:

  • tests/runtime_shell/CMakeLists.txt
📚 Learning: 2025-08-31T12:46:11.940Z
Learnt from: ThomasDevoogdt
Repo: fluent/fluent-bit PR: 9277
File: .github/workflows/pr-compile-check.yaml:147-151
Timestamp: 2025-08-31T12:46:11.940Z
Learning: In fluent-bit, the correct CMake flag for using system librdkafka is `FLB_PREFER_SYSTEM_LIB_KAFKA=ON`.

Applied to files:

  • tests/runtime_shell/CMakeLists.txt
📚 Learning: 2025-09-04T07:28:37.083Z
Learnt from: cosmo0920
Repo: fluent/fluent-bit PR: 10832
File: src/wasm/CMakeLists.txt:112-131
Timestamp: 2025-09-04T07:28:37.083Z
Learning: In fluent-bit CMake files, the user cosmo0920 prefers treating Git as a command rather than a package, emphasizing that Git is not a pkg-config retrievable package but just a command.

Applied to files:

  • tests/runtime_shell/CMakeLists.txt
🔇 Additional comments (1)
tests/runtime_shell/CMakeLists.txt (1)

20-22: Good: Linux-only test conditional appropriately addresses prior feedback.

The conditional properly gates proxy_logs_expect.sh to Linux systems, directly implementing the review feedback requesting platform-specific support. CMake syntax is correct.

Comment on lines +34 to +35
FLB_BIN=${CMAKE_BINARY_DIR}/bin/fluent-bit;\
FLB_BUILD=${CMAKE_BINARY_DIR}"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify environment variable usage in dependent test scripts.

The FLB_BUILD variable is correctly added to the test environment. However, confirm that proxy_logs_expect.sh and any sourced test utilities (e.g., build scripts for Go plugins) properly reference this variable to locate build artifacts.


🏁 Script executed:

#!/bin/bash
# Description: Verify that FLB_BUILD environment variable is used by proxy_logs_expect.sh

# Check if proxy_logs_expect.sh references FLB_BUILD
rg -n 'FLB_BUILD' tests/runtime_shell/

# Expected: Multiple references in proxy_logs_expect.sh and related build scripts

Length of output: 68


🏁 Script executed:

#!/bin/bash
# Check how test scripts currently locate build artifacts and directories

echo "=== Checking for CMAKE_BINARY_DIR or path references in test scripts ==="
rg -n 'CMAKE_BINARY_DIR|FLB_BIN' tests/runtime_shell/ -A 2 -B 2

echo ""
echo "=== Checking proxy_logs_expect.sh for build directory usage ==="
cat tests/runtime_shell/proxy_logs_expect.sh | head -50

Length of output: 14524


Remove unused FLB_BUILD environment variable or refactor test scripts to use it.

The FLB_BUILD variable is added to the test environment (CMakeLists.txt:35) but is never referenced by any test script. Scripts like proxy_logs_expect.sh instead hardcode paths like $FLB_ROOT/build/test_logs_go.so. Either remove the unused variable or update test scripts to use FLB_BUILD consistently instead of hardcoded paths.

🤖 Prompt for AI Agents
In tests/runtime_shell/CMakeLists.txt around lines 34-35, the FLB_BUILD
environment variable is being set but never used by test scripts; either remove
the FLB_BUILD assignment from this CMake file or update test scripts to
reference it instead of hardcoded paths (e.g., replace occurrences like
$FLB_ROOT/build/... with ${FLB_BUILD}/... or $FLB_BUILD/... depending on script
quoting), ensure the variable is exported to the test environment, update any
documentation/README about test env vars, and run the tests to confirm no path
regressions.

Copy link
Contributor

@cosmo0920 cosmo0920 left a comment

Choose a reason for hiding this comment

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

Looks good. With the newly added unit test case for confirming backward compatibility, this PR ensures backward compatibility.

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.

2 participants