Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] custom: Go plugin support for custom plugins to support OTel extensions #9470

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

robskillington
Copy link

@robskillington robskillington commented Oct 7, 2024

Opening this for feedback on implementation. Have this working end-to-end.

Since OpenTelemetry extensions do not require telemetry processing (unlike plugins/extensions for input/output/filter/processing/etc that do require it in FluentBit) they are relatively simple to support since they just need to be "started" and "stopped" at process boot and config hot reloads.

One primary extension that tracing end users frequently require is the ability to dynamically set head sampling on a per-service and operation combination. This is achieved by hosting a jaeger remote sampling endpoint on a collector which with Go custom plugins being able to host OpenTelemetry Go extensions becomes trivial to have FluentBit expose the same functionality (plus reduces re-implementation and helps leverage existing mature community extensions where others can contribute to easily).

As per OpenTelemetry collector documentation:

Extensions provide capabilities on top of the primary functionality of the collector. Generally, extensions are used for implementing components that can be added to the Collector, but which do not require direct access to telemetry data and are not part of the pipelines (like receivers, processors or exporters). Example extensions are: Health Check extension that responds to health check requests or PProf extension that allows fetching Collector's performance profile.


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.

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


# !! TODO: move to a Makefile

CGO_CFLAGS="-I${HOME}/src/fluent-bit/include -I${HOME}/src/fluent-bit/lib/monkey/include -I${HOME}/src/fluent-bit/build/lib/monkey/include/monkey -I${HOME}/src/fluent-bit/lib/cfl/include -I${HOME}/src/fluent-bit/lib/cfl/lib/xxhash -I${HOME}/src/fluent-bit/lib/cmetrics/include -I${HOME}/src/fluent-bit/lib/flb_libco -I${HOME}/src/fluent-bit/lib/c-ares-1.33.1/include -I${HOME}/src/fluent-bit/lib/msgpack-c/include -I${HOME}/src/fluent-bit/lib/ctraces/include -I${HOME}/src/fluent-bit/lib/ctraces/lib/mpack/src" CGO_LDFLAGS="-L${HOME}/src/fluent-bit/build/lib -lfluent-bit" sh -c 'echo CGO_CFLAGS=${CGO_CFLAGS}; echo CGO_LDFLAGS=${CGO_LDFLAGS}; go build -buildmode=c-shared -o build/bin/custom_extensions_go.so github.com/fluent/fluent-bit/plugins/custom_extensions_go'
Copy link
Member

Choose a reason for hiding this comment

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

let's avoid adding extra dev files to the repo.

@@ -0,0 +1,3 @@
module github.com/fluent/fluent-bit
Copy link
Member

Choose a reason for hiding this comment

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

let's avoid adding extra dev files to the repo.

@@ -41,7 +42,7 @@
*
* - name: shortname of the plugin.
* - description: plugin description.
* - type: input, output, filter, whatever.
* - type: input, output, filter, processor, custom.
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if processors can be written in Go today cc: @cosmo0920

Copy link
Contributor

@cosmo0920 cosmo0920 Oct 15, 2024

Choose a reason for hiding this comment

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

Currently, we can't do that. If processors can be written in Go, there is huge opportunity to handle various type of payloads including otel payloads which are belongs to traces type of events.

@edsiper
Copy link
Member

edsiper commented Oct 14, 2024

if the interface is only for OpenTelemetry Collector extensions I would suggest to rename the custom plugin

cosmo0920

This comment was marked as off-topic.

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.

For me, this PR is going to the right direction for implementing as custom plugins interface.

To handle/create Golang plugins, we manage this extension module here:
https://github.com/chronosphereio/calyptia-plugin

The committed Golang related stuffs should be handled there.

func FLBPluginConfigKey(plugin unsafe.Pointer, key string) string {
k := C.CString(key)
p := plugin
v := C.GoString(C.flb_custom_get_property(k, (*C.struct_flb_custom_instance)(p)))
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to implement flb_custom_get_property as an API here if we create custom plugin interface like as input and output:
https://github.com/fluent/fluent-bit/blob/master/src/flb_api.c#L47-L48

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.

3 participants