fix(getFLBPluginContext): use proper FLBPluginGetContext API and improve data parsing#109
Open
yuzone wants to merge 5 commits intoGoogleCloudPlatform:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes plugin context retrieval by switching to the official Fluent Bit Go API (
output.FLBPluginGetContext()).It also improves record parsing by safely handling
nil, recursively processing nested structures, and normalizing timestamps for fluentd→fluent-bit migration compatibility.Background
The previous implementation used direct pointer casting to retrieve the plugin context, which could lead to incorrect behavior. The proper
output.FLBPluginGetContext()API should be used instead.The
parseMapfunction did not handlenilinput safely, potentially causing panics.Elements inside slices (nested maps, byte slices) were not being recursively processed by
parseMap, which could cause issues when serializing data for BigQuery.When migrating from fluentd (fluent-plugins-nursery/fluent-plugin-bigquery) to fluent-bit, timestamp fields may be emitted as Unix seconds instead of the microseconds expected by the BigQuery Storage Write API, resulting in incorrect timestamp values (e.g., dates appearing as 1970-01-01).
Changes
output.FLBPluginGetContext()to correctly retrieve the plugin contextparseSlicefor[]interface{}values, enabling full recursive processingTest Plan
parseMapcovering nil input, empty maps, nested structures, and various data typesparseSlicecovering nil input, empty slices, byte slice conversion, nested maps, and mixed typesconvertTimestampFieldscovering: