fix(loki.process): Multiline no longer pass empty entry if start was flushed#5746
Merged
Conversation
e9d59cd to
831706b
Compare
edccb30 to
2f9265b
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes stage.multiline behavior where continuation lines could be appended to/flush as an empty entry after the start line was flushed early (max lines / max wait), by preserving the start-line entry metadata across flushes.
Changes:
- Preserve
startLineEntryacrossmultilineState.Reset()to keep prior start-line context for subsequent non-start lines. - Rebuild flushed entries by cloning labels/extracted/structured metadata while preserving the original
createdtimestamp. - Add a regression test covering “start line flushed before new” behavior and adjust test logger usage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/component/loki/process/stages/multiline.go | Keeps start-line context after flush and constructs flushed entries with cloned metadata + preserved created timestamp. |
| internal/component/loki/process/stages/multiline_test.go | Updates logger setup and adds a regression test for early flush behavior. |
thampiotr
reviewed
Mar 11, 2026
Co-authored-by: Piotr <17101802+thampiotr@users.noreply.github.com>
1631d44 to
a04d361
Compare
thampiotr
approved these changes
Mar 11, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Issue(s) fixed by this Pull Request
In #5702 some changes to
stage.multilinewas made to support created timestamp along with some optimizations (No longer do a deep clone). But we also made sure to always reset to a zero entry.This is a issue when a multiline entry is flushed before completion, either by max line or max wait. Then all lines that is not considered start line will be added to an empty entry and later flushed.
To fix this we revert to the old behavior where we clone the stored entry and keep it around for other lines.
Notes to the Reviewer
PR Checklist