Skip to content

plugins: add ZeroBus output plugin#11678

Open
mats16 wants to merge 7 commits intofluent:masterfrom
mats16:feat/out-zerobus
Open

plugins: add ZeroBus output plugin#11678
mats16 wants to merge 7 commits intofluent:masterfrom
mats16:feat/out-zerobus

Conversation

@mats16
Copy link
Copy Markdown

@mats16 mats16 commented Apr 6, 2026

Add a new output plugin (out_zerobus) that sends log records to Databricks ZeroBus for ingestion into Delta Lake tables.

Each flush converts Fluent Bit log events to JSON, ingests them as a batch through the ZeroBus streaming API, and waits for server-side acknowledgement before reporting success.

Key features

  • gRPC-based ingestion via the ZeroBus Rust FFI static library (libzerobus_ffi.a)
  • OAuth2 M2M authentication (client_id / client_secret)
  • Configurable record shaping: log_key filtering, time_key injection (RFC 3339 nanoseconds), raw_log_key for preserving the original record, and optional _tag injection
  • Retryable error handling: distinguishes transient from permanent errors using the SDK's is_retryable flag

Build integration

The plugin is enabled by default (FLB_OUT_ZEROBUS=ON). The prebuilt static library is provisioned automatically via cmake/zerobus-ffi.cmake:

  • Linux (x86_64, aarch64): the official release tarball is downloaded from GitHub at configure time and the correct platform library is selected automatically
  • Unsupported platforms (macOS, Windows, other architectures): the plugin is disabled automatically at configure time with an informational message
  • Manual override: users can skip the download by passing -DZEROBUS_LIB_DIR=/path/to/dir containing libzerobus_ffi.a

Platform-specific linker dependencies are handled in plugins/out_zerobus/CMakeLists.txt (CoreFoundation/Security/iconv on macOS, dl/pthread/m/resolv on Linux).


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:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

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

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

Documentation

  • Documentation required for this feature

fluent/fluent-bit-docs/pull/2537

Backporting

  • [N/A] 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

  • New Features

    • Added a Databricks ZeroBus output plugin to send logs as JSON with configurable endpoint, workspace/table, OAuth credentials, optional timestamp and tag injection, and record-field filtering/preservation.
  • Chores

    • Added a build-time option to enable the ZeroBus output and integrated platform-aware provisioning of prebuilt ZeroBus native libraries with automatic download/extraction and verification.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new Fluent Bit output plugin "out_zerobus" (C implementation and public FFI header), CMake build integration and an auto-fetching ZeroBus FFI CMake module; implements plugin init/flush/exit, msgpack→JSON conversion, batch ingestion via Rust FFI, and platform-specific link rules.

Changes

Cohort / File(s) Summary
Build options & top-level
cmake/plugins_options.cmake, CMakeLists.txt, plugins/CMakeLists.txt
Adds FLB_OUT_ZEROBUS option, registers out_zerobus plugin, and conditionally includes cmake/zerobus-ffi.cmake when enabled.
ZeroBus FFI CMake module
cmake/zerobus-ffi.cmake
New module that resolves platform, downloads/extracts prebuilt zerobus-ffi tarball, verifies SHA256, sets cached ZEROBUS_LIB_DIR/ZEROBUS_LIB_FILE, and disables FLB_OUT_ZEROBUS on unsupported platforms or failures.
Plugin build target
plugins/out_zerobus/CMakeLists.txt
New plugin CMake: defines out_zerobus target, requires ZEROBUS_LIB_FILE (fatal if missing), links the static FFI library and applies platform-specific link flags/frameworks/libs.
Public FFI header & context
plugins/out_zerobus/zerobus.h
New header with opaque SDK/Stream types, CResult, CStreamConfigurationOptions, FFI function prototypes for SDK/stream lifecycle and ingestion, ZEROBUS_RECORD_TYPE_JSON, and struct flb_out_zerobus plugin context.
Plugin implementation
plugins/out_zerobus/zerobus.c
New output plugin: validates config, normalizes URLs, creates SDK/stream (TLS handling), converts msgpack records→JSON (supports log_key, raw_log_key, time_key, add_tag), batches ingests via FFI, waits for offsets, distinguishes retryable errors, and frees resources on exit.

Sequence Diagrams

sequenceDiagram
    participant FB as Fluent Bit
    participant Plugin as out_zerobus Plugin
    participant SDK as ZeroBus SDK
    participant Stream as ZeroBus Stream

    Note over FB,Stream: Initialization (cb_zerobus_init)
    FB->>Plugin: Provide config (endpoint, workspace_url, table_name, credentials, options)
    Plugin->>SDK: zerobus_sdk_new(endpoint, workspace_url, &result)
    SDK-->>Plugin: CZerobusSdk handle / CResult
    Plugin->>SDK: zerobus_sdk_set_use_tls(sdk, use_tls)
    Plugin->>SDK: zerobus_sdk_create_stream(sdk, table_name, ..., client_id, client_secret, options, &result)
    SDK-->>Stream: CZerobusStream handle / CResult
    Plugin-->>FB: Store context (sdk, stream, config)
Loading
sequenceDiagram
    participant FB as Fluent Bit
    participant Plugin as out_zerobus Plugin
    participant Conv as JSON Converter
    participant Stream as ZeroBus Stream

    Note over FB,Stream: Flush (cb_zerobus_flush)
    FB->>Plugin: Deliver msgpack chunk
    Plugin->>Conv: Decode chunk → per-record msgpack map
    loop per record
        Conv->>Conv: Convert to JSON (apply log_key/raw_log_key/time_key/_tag)
        Conv-->>Plugin: JSON string / skip on failure
        Plugin->>Plugin: Append to batch array
    end
    Plugin->>Stream: zerobus_stream_ingest_json_records(stream, json_batch, n, &result)
    Stream-->>Plugin: offset or error (int64_t / CResult)
    Plugin->>Stream: zerobus_stream_wait_for_offset(stream, offset, &result)
    Stream-->>Plugin: Success / Retryable error / Failure
    Plugin-->>FB: Return FLB_OK / FLB_RETRY / FLB_ERROR
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels

ok-package-test

Suggested reviewers

  • edsiper
  • cosmo0920
  • niedbalski
  • patrick-stephens
  • celalettin1286

Poem

🐰 I hop through CMake, headers, and code,

I shape msgpack into JSON that flowed.
I push batched records to ZeroBus with cheer,
Await offsets, then twitch a small ear.
Carrot reward: "Logs sent — burrow clear!"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main changeset: adding a new ZeroBus output plugin to Fluent Bit.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown

@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: 8756a20a15

ℹ️ 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".

Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/out_zerobus/CMakeLists.txt`:
- Around line 14-23: The CMake snippet only handles APPLE and UNIX, so on
Windows the flb-plugin-out_zerobus target will be created without Windows linker
flags; update the if/elseif chain to handle WIN32: either add a WIN32 branch
that calls target_link_libraries(flb-plugin-out_zerobus ...) with the
Windows-specific dependencies required by the Rust FFI (or common Windows system
libs like ws2_32/advapi32/crypt32 as appropriate for your Rust static lib), or
explicitly stop Windows builds by emitting a message(FATAL_ERROR "...") when
WIN32 and FLB_OUT_ZEROBUS is enabled; modify the conditional surrounding
target_link_libraries accordingly (refer to target_link_libraries and
flb-plugin-out_zerobus) so Windows behavior is deterministic.

In `@plugins/out_zerobus/zerobus.c`:
- Around line 350-358: The init_error path currently frees ctx->endpoint,
ctx->workspace_url and ctx itself but misses releasing auto-populated config_map
SDS and list fields; update the init_error cleanup to check and destroy
ctx->table_name, ctx->client_id, ctx->client_secret, ctx->time_key,
ctx->raw_log_key with flb_sds_destroy and, for ctx->log_keys, call
flb_slist_destroy then flb_free on ctx->log_keys before flb_free(ctx) so all
allocated config_map resources are freed on initialization failure (referencing
the init_error label and the
ctx->table_name/client_id/client_secret/time_key/raw_log_key/log_keys symbols).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c50e0269-1a75-4958-9d15-c0de0134c98d

📥 Commits

Reviewing files that changed from the base of the PR and between 3e414ac and 8756a20.

📒 Files selected for processing (5)
  • cmake/plugins_options.cmake
  • plugins/CMakeLists.txt
  • plugins/out_zerobus/CMakeLists.txt
  • plugins/out_zerobus/zerobus.c
  • plugins/out_zerobus/zerobus.h

@mats16 mats16 force-pushed the feat/out-zerobus branch from cbaf632 to 84261c1 Compare April 6, 2026 22:48
mats16 added 3 commits April 7, 2026 07:49
Introduce the ZeroBus output plugin for Fluent Bit, enabling integration with Databricks ZeroBus. This commit includes the necessary CMake configuration, plugin registration, and implementation files. The plugin is disabled by default and requires specific library paths to be set for proper functionality.

Signed-off-by: Kazuki Matsuda <kazuki.matsuda@databricks.com>
Signed-off-by: mats <mats.kazuki@gmail.com>
Changed the configuration property from 'zerobus_endpoint' to 'endpoint' to enforce the inclusion of a URL scheme (http:// or https://). Updated related error messages and context handling to reflect this change. The workspace_url will now automatically prepend https:// if no scheme is provided.

Signed-off-by: Kazuki Matsuda <kazuki.matsuda@databricks.com>
Signed-off-by: mats <mats.kazuki@gmail.com>
…e documentation

Added a fatal error message for Windows builds to indicate that the ZeroBus plugin is not supported. Enhanced code documentation by adding comments to clarify the purpose of several functions, including URL scheme validation, timestamp formatting, and plugin initialization and cleanup processes.

Signed-off-by: Kazuki Matsuda <kazuki.matsuda@databricks.com>
Signed-off-by: mats <mats.kazuki@gmail.com>
@mats16 mats16 force-pushed the feat/out-zerobus branch from 84261c1 to 919de56 Compare April 6, 2026 22:49
Copy link
Copy Markdown

@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.

♻️ Duplicate comments (1)
plugins/out_zerobus/zerobus.c (1)

355-363: ⚠️ Potential issue | 🟠 Major

Memory leak: free config_map fields in init_error path.

The init_error path frees endpoint and workspace_url but not the auto-populated config_map fields (table_name, client_id, client_secret, time_key, raw_log_key, log_keys). Since flb_output_set_context() is only called on success (line 352), the framework cannot clean up these fields when init fails.

,

Proposed fix
 init_error:
     if (ctx->endpoint) {
         flb_sds_destroy(ctx->endpoint);
     }
     if (ctx->workspace_url) {
         flb_sds_destroy(ctx->workspace_url);
     }
+    if (ctx->table_name) {
+        flb_sds_destroy(ctx->table_name);
+    }
+    if (ctx->client_id) {
+        flb_sds_destroy(ctx->client_id);
+    }
+    if (ctx->client_secret) {
+        flb_sds_destroy(ctx->client_secret);
+    }
+    if (ctx->time_key) {
+        flb_sds_destroy(ctx->time_key);
+    }
+    if (ctx->raw_log_key) {
+        flb_sds_destroy(ctx->raw_log_key);
+    }
+    if (ctx->log_keys) {
+        flb_slist_destroy(ctx->log_keys);
+        flb_free(ctx->log_keys);
+    }
     flb_free(ctx);
     return -1;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/out_zerobus/zerobus.c` around lines 355 - 363, The init_error cleanup
path currently frees ctx->endpoint and ctx->workspace_url but omits the
config_map string fields populated earlier, causing leaks; in the init_error
block (label init_error) destroy each of ctx->table_name, ctx->client_id,
ctx->client_secret, ctx->time_key, ctx->raw_log_key, and ctx->log_keys with
flb_sds_destroy if non-NULL before calling flb_free(ctx), mirroring the
destruction done on success (and ensure this only runs on the error path since
flb_output_set_context() is invoked on success).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@plugins/out_zerobus/zerobus.c`:
- Around line 355-363: The init_error cleanup path currently frees ctx->endpoint
and ctx->workspace_url but omits the config_map string fields populated earlier,
causing leaks; in the init_error block (label init_error) destroy each of
ctx->table_name, ctx->client_id, ctx->client_secret, ctx->time_key,
ctx->raw_log_key, and ctx->log_keys with flb_sds_destroy if non-NULL before
calling flb_free(ctx), mirroring the destruction done on success (and ensure
this only runs on the error path since flb_output_set_context() is invoked on
success).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b43c433-0812-413f-96c9-280aed9cd161

📥 Commits

Reviewing files that changed from the base of the PR and between cbaf632 and 84261c1.

📒 Files selected for processing (5)
  • cmake/plugins_options.cmake
  • plugins/CMakeLists.txt
  • plugins/out_zerobus/CMakeLists.txt
  • plugins/out_zerobus/zerobus.c
  • plugins/out_zerobus/zerobus.h
✅ Files skipped from review due to trivial changes (3)
  • cmake/plugins_options.cmake
  • plugins/CMakeLists.txt
  • plugins/out_zerobus/zerobus.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/out_zerobus/CMakeLists.txt

mats16 added 2 commits April 7, 2026 10:41
Updated the ZeroBus plugin to automatically prepend https:// to both the endpoint and workspace_url if no scheme is provided. Revised related comments and documentation to reflect this change, enhancing clarity for users.

Signed-off-by: mats <mats.kazuki@gmail.com>
Introduced the ZeroBus output plugin for Fluent Bit, allowing integration with Databricks ZeroBus. The plugin is now enabled by default in the configuration. Added CMake support to include the necessary ZeroBus FFI library setup, and enhanced documentation for clarity on usage and platform compatibility.

Signed-off-by: mats <mats.kazuki@gmail.com>
@mats16
Copy link
Copy Markdown
Author

mats16 commented Apr 7, 2026

1. Example configuration file

[SERVICE]
    flush     1
    log_level debug

[INPUT]
    name  dummy
    dummy {"message":"hello from fluent-bit","level":"info"}
    tag   test.zerobus

[OUTPUT]
    name          zerobus
    match         test.*
    endpoint      https://your-zerobus-endpoint.example.com
    workspace_url https://your-workspace.databricks.com
    table_name    catalog.schema.table
    client_id     your-client-id
    client_secret your-client-secret
    log_key       message, level
    time_key      _time    

2. Debug log output

Fluent Bit v5.0.2
* Copyright (C) 2015-2026 The Fluent Bit Authors
* Fluent Bit is a CNCF graduated project under the Fluent organization
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____ 
|  ___| |                | |   | ___ (_) |         |  ___||  _  |
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   _|___ \ | |/' |
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \|  /| |
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V //\__/ /\ |_/ /
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)\___/


[2026/04/07 02:58:04.677] [ info] Configuration:
[2026/04/07 02:58:04.677] [ info]  flush time     | 1.000000 seconds
[2026/04/07 02:58:04.677] [ info]  grace          | 5 seconds
[2026/04/07 02:58:04.677] [ info]  daemon         | 0
[2026/04/07 02:58:04.677] [ info] ___________
[2026/04/07 02:58:04.677] [ info]  inputs:
[2026/04/07 02:58:04.677] [ info]      dummy
[2026/04/07 02:58:04.677] [ info] ___________
[2026/04/07 02:58:04.677] [ info]  filters:
[2026/04/07 02:58:04.677] [ info] ___________
[2026/04/07 02:58:04.677] [ info]  outputs:
[2026/04/07 02:58:04.677] [ info]      zerobus.0
[2026/04/07 02:58:04.677] [ info] ___________
[2026/04/07 02:58:04.677] [ info]  collectors:
[2026/04/07 02:58:04.678] [ info] [fluent bit] version=5.0.2, commit=6dbccf7213, pid=1
[2026/04/07 02:58:04.678] [debug] [engine] coroutine stack size: 196608 bytes (192.0K)
[2026/04/07 02:58:04.678] [ info] [storage] ver=1.5.4, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2026/04/07 02:58:04.678] [ info] [simd    ] NEON
[2026/04/07 02:58:04.678] [ info] [cmetrics] version=2.1.1
[2026/04/07 02:58:04.678] [ info] [ctraces ] version=0.7.1
[2026/04/07 02:58:04.678] [ info] [input:dummy:dummy.0] initializing
[2026/04/07 02:58:04.678] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2026/04/07 02:58:04.678] [debug] [dummy:dummy.0] created event channels: read=21 write=22
[2026/04/07 02:58:04.678] [debug] [zerobus:zerobus.0] created event channels: read=23 write=24
[2026/04/07 02:58:05.127] [ info] [output:zerobus:zerobus.0] connected to https://5099015744649857.zerobus.ap-northeast-1.cloud.databricks.com, table: mats.sandbox.zerobus_test
[2026/04/07 02:58:05.127] [ info] [sp] stream processor started
[2026/04/07 02:58:05.127] [ info] [engine] Shutdown Grace Period=5, Shutdown Input Grace Period=2
[2026/04/07 02:58:05.128] [ info] [output:zerobus:zerobus.0] worker #0 started
[2026/04/07 02:58:06.817] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:06.817] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:06.842] [debug] [out flush] cb_destroy coro_id=0
[2026/04/07 02:58:06.842] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
[2026/04/07 02:58:07.814] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:07.814] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:07.848] [debug] [out flush] cb_destroy coro_id=1
[2026/04/07 02:58:07.848] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
[2026/04/07 02:58:08.817] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:08.817] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:08.853] [debug] [out flush] cb_destroy coro_id=2
[2026/04/07 02:58:08.853] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
[2026/04/07 02:58:09.812] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:09.812] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:09.858] [debug] [out flush] cb_destroy coro_id=3
[2026/04/07 02:58:09.858] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
[2026/04/07 02:58:10.818] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:10.818] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:10.865] [debug] [out flush] cb_destroy coro_id=4
[2026/04/07 02:58:10.865] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
[2026/04/07 02:58:11.817] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:11.817] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:11.871] [debug] [out flush] cb_destroy coro_id=5
[2026/04/07 02:58:11.871] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
[2026/04/07 02:58:12.815] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:12.815] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:12.877] [debug] [out flush] cb_destroy coro_id=6
[2026/04/07 02:58:12.877] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
[2026/04/07 02:58:13.816] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:13.816] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:13.881] [debug] [out flush] cb_destroy coro_id=7
[2026/04/07 02:58:13.881] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
^C[2026/04/07 02:58:14] [engine] caught signal (SIGINT)
[2026/04/07 02:58:14.061] [debug] [task] created task=0xffffad42f360 id=0 OK
[2026/04/07 02:58:14.061] [debug] [output:zerobus:zerobus.0] task_id=0 assigned to thread #0
[2026/04/07 02:58:14.061] [ warn] [engine] service will shutdown in max 5 seconds
[2026/04/07 02:58:14.061] [debug] [engine] task 0 already scheduled to run, not re-scheduling it.
[2026/04/07 02:58:14.061] [ info] [engine] pausing all inputs..
[2026/04/07 02:58:14.061] [ info] [input] pausing dummy.0
[2026/04/07 02:58:14.082] [debug] [out flush] cb_destroy coro_id=8
[2026/04/07 02:58:14.082] [debug] [task] destroy task=0xffffad42f360 (task_id=0)
[2026/04/07 02:58:14.816] [ info] [engine] service has stopped (0 pending tasks)
[2026/04/07 02:58:14.816] [ info] [input] pausing dummy.0
[2026/04/07 02:58:14.816] [ info] [output:zerobus:zerobus.0] thread worker #0 stopping...
[2026/04/07 02:58:14.816] [ info] [output:zerobus:zerobus.0] thread worker #0 stopped

3.Valgrind results

Tested on Linux (Docker) with timeout 10, --leak-check=full.

Config definitely lost still reachable errors
out_null 0 0 1,732
out_zerobus 0 102,476 bytes 3,061
  • No memory leaks (definitely lost = 0)
  • "still reachable" memory is entirely from the Rust async runtime
    (tokio, reqwest, tower) inside libzerobus_ffi.a — expected behavior
  • No errors in stack traces originate from zerobus.c plugin code
  • Baseline core errors (1,732) account for the majority of the total

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (3)
plugins/out_zerobus/zerobus.c (2)

418-425: Consider FLB_ERROR instead of FLB_RETRY for decoder init failure.

Decoder initialization failures typically indicate corrupted or malformed chunk data that won't be fixed by retrying. Returning FLB_RETRY will cause the engine to reschedule the same corrupted data repeatedly until retry limits are exhausted.

🔧 Suggested fix
     ret = flb_log_event_decoder_init(&log_decoder,
                                      (char *) event_chunk->data,
                                      event_chunk->size);
     if (ret != FLB_EVENT_DECODER_SUCCESS) {
         flb_plg_error(ctx->ins,
                       "log event decoder initialization error: %d", ret);
-        FLB_OUTPUT_RETURN(FLB_RETRY);
+        FLB_OUTPUT_RETURN(FLB_ERROR);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/out_zerobus/zerobus.c` around lines 418 - 425, The decoder init error
branch in plugins/out_zerobus/zerobus.c currently returns FLB_RETRY after
flb_log_event_decoder_init(&log_decoder, (char *) event_chunk->data,
event_chunk->size) fails; change the control flow to return FLB_ERROR instead of
FLB_RETRY (keep the existing flb_plg_error call and context/variables:
log_decoder, event_chunk, ret, ctx->ins) so corrupted/malformed chunk data is
not rescheduled for retry.

613-623: Consider adding FLB_OUTPUT_SYNCHRONOUS for explicit blocking behavior.

With workers = 1 and a blocking wait_for_offset call in the flush function, adding the FLB_OUTPUT_SYNCHRONOUS flag (2048) would make the engine's task serialization intent explicit. This flag indicates "run one task at a time, no flush cycle limit" and is appropriate for blocking output operations.

The current implementation works correctly without it (as other single-worker plugins like kinesis_streams demonstrate with flags = 0), but the flag clarifies to the engine that this output requires synchronous task handling.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/out_zerobus/zerobus.c` around lines 613 - 623, Add the
FLB_OUTPUT_SYNCHRONOUS flag to the out_zerobus_plugin declaration to make
blocking behavior explicit: in the struct flb_output_plugin instance named
out_zerobus_plugin set .flags to include FLB_OUTPUT_SYNCHRONOUS (bit 2048)
alongside any existing flags; this documents that cb_zerobus_flush (which
performs the blocking wait_for_offset) should be treated as synchronous and run
one task at a time when workers = 1.
cmake/zerobus-ffi.cmake (1)

68-82: Partial extraction could leave broken state.

If extraction fails partway through, the native/ directory may exist but be incomplete. Subsequent cmake runs would skip extraction (line 70 check passes) but the library verification at line 87 would disable the plugin. Consider checking for the library file directly instead of the directory:

🔧 Suggested improvement
 # Extract the tarball
 set(_ZEROBUS_EXTRACT_DIR "${CMAKE_BINARY_DIR}")
-if(NOT EXISTS "${_ZEROBUS_EXTRACT_DIR}/native")
+set(_ZEROBUS_LIB_PATH "${_ZEROBUS_EXTRACT_DIR}/native/${_ZEROBUS_PLATFORM}/libzerobus_ffi.a")
+if(NOT EXISTS "${_ZEROBUS_LIB_PATH}")
   execute_process(
     COMMAND ${CMAKE_COMMAND} -E tar xzf "${_ZEROBUS_TARBALL}"
     WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmake/zerobus-ffi.cmake` around lines 68 - 82, The current existence check
uses the directory "${_ZEROBUS_EXTRACT_DIR}/native" which can be present after a
partial extract; change the logic to check for the actual expected library
artifact (e.g. the platform-specific file under
"${_ZEROBUS_EXTRACT_DIR}/native", such as libzerobus*.so/.dylib/.dll) before
skipping extraction, and if extraction fails via execute_process store/inspect
_EXTRACT_RESULT and remove the partial "${_ZEROBUS_EXTRACT_DIR}/native" to avoid
leftover broken state before returning and calling FLB_OPTION(FLB_OUT_ZEROBUS
OFF); ensure the new check replaces the directory check and that the
execute_process step runs whenever the expected library file is missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cmake/zerobus-ffi.cmake`:
- Around line 68-82: The current existence check uses the directory
"${_ZEROBUS_EXTRACT_DIR}/native" which can be present after a partial extract;
change the logic to check for the actual expected library artifact (e.g. the
platform-specific file under "${_ZEROBUS_EXTRACT_DIR}/native", such as
libzerobus*.so/.dylib/.dll) before skipping extraction, and if extraction fails
via execute_process store/inspect _EXTRACT_RESULT and remove the partial
"${_ZEROBUS_EXTRACT_DIR}/native" to avoid leftover broken state before returning
and calling FLB_OPTION(FLB_OUT_ZEROBUS OFF); ensure the new check replaces the
directory check and that the execute_process step runs whenever the expected
library file is missing.

In `@plugins/out_zerobus/zerobus.c`:
- Around line 418-425: The decoder init error branch in
plugins/out_zerobus/zerobus.c currently returns FLB_RETRY after
flb_log_event_decoder_init(&log_decoder, (char *) event_chunk->data,
event_chunk->size) fails; change the control flow to return FLB_ERROR instead of
FLB_RETRY (keep the existing flb_plg_error call and context/variables:
log_decoder, event_chunk, ret, ctx->ins) so corrupted/malformed chunk data is
not rescheduled for retry.
- Around line 613-623: Add the FLB_OUTPUT_SYNCHRONOUS flag to the
out_zerobus_plugin declaration to make blocking behavior explicit: in the struct
flb_output_plugin instance named out_zerobus_plugin set .flags to include
FLB_OUTPUT_SYNCHRONOUS (bit 2048) alongside any existing flags; this documents
that cb_zerobus_flush (which performs the blocking wait_for_offset) should be
treated as synchronous and run one task at a time when workers = 1.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8a58ab51-fbf3-49af-9c7c-c113e19e99a3

📥 Commits

Reviewing files that changed from the base of the PR and between 84261c1 and 24f796a.

📒 Files selected for processing (7)
  • CMakeLists.txt
  • cmake/plugins_options.cmake
  • cmake/zerobus-ffi.cmake
  • plugins/CMakeLists.txt
  • plugins/out_zerobus/CMakeLists.txt
  • plugins/out_zerobus/zerobus.c
  • plugins/out_zerobus/zerobus.h
✅ Files skipped from review due to trivial changes (3)
  • cmake/plugins_options.cmake
  • plugins/CMakeLists.txt
  • plugins/out_zerobus/zerobus.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/out_zerobus/CMakeLists.txt

… handling

Enhanced the CMake configuration for the ZeroBus FFI by introducing a new variable, ZEROBUS_LIB_FILE, to specify the full path to the static library. Updated related logic to ensure proper handling of library paths across different platforms, including improved error messaging for unsupported architectures. This change aims to streamline the build process and enhance clarity in library management.

Signed-off-by: mats <mats.kazuki@gmail.com>
Copy link
Copy Markdown

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmake/zerobus-ffi.cmake`:
- Around line 14-19: The manual override branch that sets ZEROBUS_LIB_FILE when
ZEROBUS_LIB_DIR is provided must validate the constructed path exists before
returning; update the block that references ZEROBUS_LIB_DIR and sets
ZEROBUS_LIB_FILE to test the full file path (built from ZEROBUS_LIB_DIR,
CMAKE_STATIC_LIBRARY_PREFIX, zerobus_ffi, and CMAKE_STATIC_LIBRARY_SUFFIX) using
CMake's file(EXISTS ...) or if(NOT EXISTS ...) check and emit a clear error
(e.g., message(FATAL_ERROR ...)) or fallback to auto-discovery behavior if the
file is missing, mirroring the validation logic used by the auto-discovery code
that currently checks existence later.
- Around line 88-100: The guard currently checks for
"${_ZEROBUS_EXTRACT_DIR}/native" which can be stale; change the extraction guard
to test for the actual expected library file instead (e.g. the platform-specific
artifact under "${_ZEROBUS_EXTRACT_DIR}/native", not the directory itself)
before skipping extraction, using the same variables (_ZEROBUS_EXTRACT_DIR,
_ZEROBUS_TARBALL) and keeping the extraction flow and error handling
(RESULT_VARIABLE _EXTRACT_RESULT / message / FLB_OPTION(FLB_OUT_ZEROBUS OFF) /
return()) intact so we only skip extraction when the real library file is
present and valid.
- Around line 28-31: Update the processor-match condition that sets
_ZEROBUS_PLATFORM so it also recognizes lowercase "arm64" (and matches case
consistently with the windows-setup pattern); modify the
if(CMAKE_SYSTEM_PROCESSOR MATCHES ...) check used to set _ZEROBUS_PLATFORM so
the regex includes arm64 in any case (e.g., use a case-insensitive or anchored
alternation like ^(AARCH64|ARM64|aarch64|arm64)$ or a (?i) flag) to ensure
CMAKE_SYSTEM_PROCESSOR correctly selects "linux-aarch64".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c79dee6-0431-4f68-9d4a-533bbd0aebb5

📥 Commits

Reviewing files that changed from the base of the PR and between 24f796a and 5843a3d.

📒 Files selected for processing (2)
  • cmake/zerobus-ffi.cmake
  • plugins/out_zerobus/CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/out_zerobus/CMakeLists.txt

Added a check to verify the existence of the ZeroBus FFI library file, providing a status message if the library is not found. Updated platform detection logic to include case variations for ARM architecture. Improved extraction condition to ensure the correct library file is checked during the build process.

Signed-off-by: mats <mats.kazuki@gmail.com>
@mats16
Copy link
Copy Markdown
Author

mats16 commented Apr 7, 2026

Ready for review. Let me know if anything needs clarification.

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