[bug] Fixed silent log drops when more than 1000 lines.#49818
[bug] Fixed silent log drops when more than 1000 lines.#49818krshn-ptl wants to merge 2 commits into
Conversation
|
Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib. Important reminders:
|
Pull request dashboard statusStatus last refreshed: 2026-07-23 00:30:14 UTC.
This automated status or its linked feedback items may be incorrect. If something looks wrong, please report it with the result you expected. If you believe this pull request is incorrectly routed as waiting on the author, comment |
|
/workflow-approve |
There was a problem hiding this comment.
Pull request overview
Fixes a bug in the textencoding extension where UnmarshalLogs could silently return only the first decoded batch when inputs exceed the default stream-decoder flush item threshold (1000), leading to dropped log records.
Changes:
- Disable item-count based flushing in
UnmarshalLogsby addingencoding.WithFlushItems(0)alongsideWithFlushBytes(0). - Add a regression test that verifies
UnmarshalLogsreturns all records when input contains >1000 log lines. - Add a changelog entry documenting the bug fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
extension/encoding/textencodingextension/text.go |
Ensures UnmarshalLogs does not flush early on item count, preventing truncation for large inputs. |
extension/encoding/textencodingextension/text_test.go |
Adds a regression test covering >1000-line inputs to prevent future silent truncation regressions. |
.chloggen/main.yaml |
Adds release note entry for the bug fix (needs filename convention alignment). |
Comments suppressed due to low confidence (1)
extension/encoding/textencodingextension/text_test.go:13
- The import block is not gofmt-compliant (std imports are out of order: "strings" appears before "io"). This will typically fail gofmt/lint checks in CI.
import (
"bytes"
"fmt"
"strings"
"io"
"regexp"
"testing"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Use this changelog template to create an entry for release notes. | ||
|
|
||
| # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
| change_type: bug_fix | ||
|
|
||
| # The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog) | ||
| component: extension/encoding |
There was a problem hiding this comment.
Not sure about this comment. Please confirm if such change is required
Co-authored-by: Paulo Dias <44772900+paulojmdias@users.noreply.github.com>
|
@krshn-ptl can you please look into CI errors? |
Description
When extracting lines of logs with text encoding, the code ensures that logs are processed in chunks but flushed at once. The default flush values are 1000x1024x1024 bytes or 1000 items. During streaming, we override the defaults so that flushes happen at once. We override the default for bytes, but the items override was missed. This causes logs greater than 1000 lines to silently drop.
The PR adds a change to override the default items to 0 so that the flush happens for all logs once they are prepared. There were two ways to fix this:
I chose the first approach because I may not have proper context on why flush-all was done in the first place.
History (How I came across this, and design choices)
I am using OTEL for extracting AWS ELB logs. As per the standard AWS setup, these logs are delivered as S3 objects that I need to onboard into my DB. For this, I use the
awss3receiverwith a queue in place via which notifications come for every new S3 file creation. Since these are compressed objects, we need extensions to extract and process each line of the log separately.I am using
textencodinginstead of theawslogencodingextension because that has two major blockers for me:By using text encoding, I wrote a transformer over it to mimic the extraction layer at my config end. This helps me with any type of customization as well.
While doing this, I noticed logs were getting dropped. After debugging, I found this bug.
Testing
I've added a test to verify that if the streamed log is more than 1000, then it shouldn't drop it, and all logs are to be flushed. (AI-generated test case)
Authorship