Skip to content

proxy: input plugins can now emit metrics and traces event types#11915

Open
seblaz wants to merge 1 commit into
fluent:masterfrom
seblaz:feat/proxy-input-event-type
Open

proxy: input plugins can now emit metrics and traces event types#11915
seblaz wants to merge 1 commit into
fluent:masterfrom
seblaz:feat/proxy-input-event-type

Conversation

@seblaz

@seblaz seblaz commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Allow proxy input plugins (e.g. Go plugins via fluent-bit-go) to emit metrics and traces event types, not just logs.

The proxy input collect callback previously hardcoded flb_input_log_append, making it impossible for proxy-based input plugins to feed the metrics or traces pipeline. This change reads event_type from the proxy plugin definition and dispatches to the appropriate append function:

  • FLB_INPUT_METRICS → decode msgpack with cmt_decode_msgpack_create, append via flb_input_metrics_append
  • FLB_INPUT_TRACES → decode msgpack with ctr_decode_msgpack_create, append via flb_input_trace_append
  • default (0 / logs) → original flb_input_log_append behavior, fully backwards compatible

The output proxy side already supports event_type with the same pattern; this brings input plugins to parity. Error handling mirrors fw_prot.c:append_log.

The event_type field already exists on flb_plugin_proxy_def (unused for inputs until now), so Go plugins can set it during FLBPluginRegister without any SDK-side C changes — though the fluent-bit-go SDK will need to expose the field to users.

Fixes #11914


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

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

  • New Features

    • Proxy input now ingests metrics and traces in addition to logs when using the Go proxy path
    • Automatic selection of the appropriate payload decoder based on incoming event type
  • Bug Fixes

    • Improved error handling and resource cleanup during metric and trace ingestion

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 603154a4-4cec-4d2b-904f-c91a98ff4389

📥 Commits

Reviewing files that changed from the base of the PR and between 59f97d1 and 0f86281.

📒 Files selected for processing (1)
  • src/flb_plugin_proxy.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/flb_plugin_proxy.c

📝 Walkthrough

Walkthrough

The proxy input collection callback now routes metrics, traces, and logs based on the proxy definition's event_type, adding msgpack decoder support for metrics/traces and calling the corresponding flb_input_*_append functions, with unified cleanup and error handling.

Changes

Event-Type Routing for Proxy Input Plugins

Layer / File(s) Summary
Msgpack decoder headers and state
src/flb_plugin_proxy.c
Adds msgpack decoder header includes for metrics and traces and extends the collection callback's local state to track decoder instances for metrics and traces.
Event-type dispatch and append routing
src/flb_plugin_proxy.c
Collection callback reads event_type from the proxy definition and dispatches to flb_input_metrics_append() for metrics, flb_input_trace_append() for traces, or flb_input_log_append() for logs. Includes msgpack decoding for metrics/traces, error handling for decode/append failures, ownership semantics for trace append, and a generic "No data ingested" message.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • fluent/fluent-bit#11011: Adds the event_type field to the proxy definition structure that this PR reads and routes on.

Suggested reviewers

  • edsiper
  • cosmo0920
  • koleini

Poem

🐰 A proxy in blue now sees the whole view—
metrics and traces, not just logs in queue,
event_type nudges which path to pursue,
decoders hum, appenders queue anew,
cleanup hops in—bye-bye memory stew.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: enabling proxy input plugins to emit metrics and traces event types in addition to logs.
Linked Issues check ✅ Passed The PR addresses all coding objectives from issue #11914: implements event_type dispatching to correct append functions (metrics/traces), maintains backwards compatibility for logs, and properly handles error cases.
Out of Scope Changes check ✅ Passed All changes in src/flb_plugin_proxy.c are directly related to implementing the event_type dispatch mechanism for proxy input plugins as specified in the linked issue.

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

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/flb_plugin_proxy.c

src/flb_plugin_proxy.c:25:10: fatal error: 'monkey/mk_core.h' file not found
25 | #include <monkey/mk_core.h>
| ^~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/0f862815fb8ccd5584804bbec4ba3340d59ed25b-1450925bb990981e/tmp/clang_command_.tmp.9bf6ca.txt
++Contents of '/tmp/coderabbit-infer/0f862815fb8ccd5584804bbec4ba3340d59ed25b-1450925bb990981e/tmp/clang_command_.tmp.9bf6ca.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disabl

... [truncated 716 characters] ...

/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/1450925bb990981e/file.o" "-x" "c"
"src/flb_plugin_proxy.c" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


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.

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

Copy link
Copy Markdown

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: 79248c1980

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/flb_plugin_proxy.c
Comment on lines +108 to +124
if (event_type == FLB_INPUT_METRICS) {
ret = cmt_decode_msgpack_create(&cmt, (char *) data, len, &offset);
if (ret != CMT_DECODE_MSGPACK_SUCCESS) {
flb_error("[proxy] failed to decode metrics msgpack (error %d)", ret);
proxy_go_input_cleanup(ctx, data);
return -1;
}
ret = flb_input_metrics_append(ins, NULL, 0, cmt);
if (ret != 0) {
flb_error("[proxy] could not append metrics, ret=%d", ret);
cmt_decode_msgpack_destroy(cmt);
proxy_go_input_cleanup(ctx, data);
return -1;
}
cmt_decode_msgpack_destroy(cmt);
}
else if (event_type == FLB_INPUT_TRACES) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Map proxy input event types from output constants

For a proxy plugin that follows the existing proxy event_type convention used by outputs, metrics are registered as FLB_OUTPUT_METRICS (value 2) and traces as FLB_OUTPUT_TRACES (value 4); this new input path compares the same def->event_type against FLB_INPUT_METRICS/FLB_INPUT_TRACES (1/2). In that scenario a metrics-producing Go input is decoded as traces and a traces-producing input falls through to the log append path, so the feature fails for SDKs exposing the already-established proxy output constants unless this registration value is translated by plugin type.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/flb_plugin_proxy.c`:
- Around line 140-143: The current fallback in flb_plugin_proxy.c routes any
non-handled event_type into flb_input_log_append; update the branch so only
FLB_INPUT_LOGS is passed to flb_input_log_append and all other event_type values
(e.g., FLB_INPUT_BLOBS, FLB_INPUT_PROFILES) are rejected immediately: replace
the bare else with an explicit if (event_type == FLB_INPUT_LOGS) { ret =
flb_input_log_append(...); } else { set ret to an error value, emit an
explanatory error/log mentioning the unexpected event_type and the plugin/input
instance, and return/fail fast instead of treating it as logs } to preserve the
logs vs non-logs contract and avoid misrouting payloads.
🪄 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: 218b2e4c-0b60-4363-b0d7-c551c4685541

📥 Commits

Reviewing files that changed from the base of the PR and between f4f95cd and 59f97d1.

📒 Files selected for processing (1)
  • src/flb_plugin_proxy.c

Comment thread src/flb_plugin_proxy.c Outdated
Read event_type from the proxy definition and dispatch to the
appropriate append function (flb_input_metrics_append or
flb_input_trace_append) in the collect callback, mirroring how
the output proxy side already handles event_type.

Metrics and traces are decoded from msgpack using cmt_decode_msgpack
and ctr_decode_msgpack respectively before being appended. Logs remain
the default (event_type == FLB_INPUT_LOGS) to preserve backwards
compatibility. Unsupported event types are rejected with an error.

Error handling mirrors the pattern in fw_prot.c:append_log: return
values are checked, resources are freed on failure, and ctr ownership
is not assumed on the traces success path since flb_input_trace_append
takes ownership of the context.

fluent#11914

Signed-off-by: seblaz <sebastian.blazquez96@gmail.com>
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.

feat: flb_plugin_proxy input plugins should support metrics event type

1 participant