out_opentelemetry: add option to preserve fields in log body #10304
+36
−11
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
logs_body_preserve
that allows record fields to be retained in the log body when they're used/processed by the OpenTelemetry output pluginDetails
The OpenTelemetry Protocol (OTLP) format separates data into two main parts:
The OpenTelemetry output plugin converts Fluent Bit records to this format by:
The key issue is in log_record_set_attributes function (line ~231):
When the processor_calyptia adds the field "hello: world", this happens:
In contrast, the stdout output just prints whatever it receives, so you see all fields preserved.
The logs_body_preserve option now strictly does what its name suggests - it preserves record fields in the log body without forcing them to be added as attributes.
Fields are only added to attributes if:
With this change:
Configuration Example
Expected Output
When the OpenTelemetry output plugin sends logs to a receiver with
logs_body_preserve: true
, the log body should contain all fields from the original record:Without this option, the field used to populate the log body would be removed, resulting in only one of the fields being present in the output.