Skip to content

Conversation

mauri870
Copy link
Member

@mauri870 mauri870 commented Jul 30, 2025

Proposed commit message

It appears that the otelconsumer's Publish method returning an error prevented batches from being retried, despite the batch.Retry call. As a result, events with initial errors were never delivered. Changing the return value to nil fixed the issue.

Additionally, use OTel's receivertest.CheckConsumeContract to test filebeatreceiver. Some piping is required to forward the unique test ID attribute expected by receivertest.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

How to test this PR locally

$ go test -timeout 5m -tags integration,unit -run ^TestConsumeContract$ ./x-pack/filebeat/fbreceiver -v -count=1

=== RUN   TestConsumeContract
=== RUN   TestConsumeContract/always_succeed
Sent 100, accepted=100, expected dropped=0, non-permanent errors retried=0
=== RUN   TestConsumeContract/random_non_permanent_error
Sent 100, accepted=100, expected dropped=0, non-permanent errors retried=88
=== RUN   TestConsumeContract/random_permanent_error
Sent 100, accepted=50, expected dropped=50, non-permanent errors retried=0
=== RUN   TestConsumeContract/random_error
Sent 100, accepted=45, expected dropped=55, non-permanent errors retried=48
--- PASS: TestConsumeContract (12.11s)
    --- PASS: TestConsumeContract/always_succeed (3.03s)
    --- PASS: TestConsumeContract/random_non_permanent_error (3.03s)
    --- PASS: TestConsumeContract/random_permanent_error (3.03s)
    --- PASS: TestConsumeContract/random_error (3.03s)
PASS
ok  	github.com/elastic/beats/v7/x-pack/filebeat/fbreceiver	12.152s
./script/stresstest.sh --tags unit ./x-pack/filebeat/fbreceiver ^TestConsumeContract$
3m50s: 576 runs so far, 0 failures, 32 active

Related issues

@mauri870 mauri870 added this to the otel milestone Jul 30, 2025
@mauri870 mauri870 self-assigned this Jul 30, 2025
@mauri870 mauri870 added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches backport-8.19 Automated backport to the 8.19 branch labels Jul 30, 2025
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jul 30, 2025
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@mauri870
Copy link
Member Author

/test

@mauri870 mauri870 force-pushed the receivertest-otelconsumer branch from 85aad35 to 582b6fb Compare July 31, 2025 11:17
@mauri870 mauri870 changed the title otel: use receivertest to test fbreceiver otel: use receivertest to test fbreceiver, fix retries in otelconsumer Jul 31, 2025
@mauri870 mauri870 changed the title otel: use receivertest to test fbreceiver, fix retries in otelconsumer otel: fix retries in otelconsumer and add receivertest for fbreceiver Jul 31, 2025
@mauri870 mauri870 marked this pull request as ready for review July 31, 2025 11:38
@mauri870 mauri870 requested review from a team as code owners July 31, 2025 11:38
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@mauri870 mauri870 force-pushed the receivertest-otelconsumer branch from d396bb7 to ef779a4 Compare August 5, 2025 12:42
Copy link
Contributor

@khushijain21 khushijain21 left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this!

@mauri870 mauri870 requested a review from khushijain21 August 5, 2025 15:02
@mauri870 mauri870 changed the title otel: fix retries in otelconsumer and add receivertest for fbreceiver otel: fix retries in otelconsumer and add receivertest test suite Aug 5, 2025
Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

LGTM. Thank You.

Copy link
Collaborator

@pierrehilbert pierrehilbert left a comment

Choose a reason for hiding this comment

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

Based on Lee's approval, I'm giving mine.

@mauri870 mauri870 merged commit ee17a83 into elastic:main Aug 6, 2025
206 checks passed
Copy link
Contributor

github-actions bot commented Aug 6, 2025

@Mergifyio backport 9.0 9.1

Copy link
Contributor

mergify bot commented Aug 6, 2025

backport 9.0 9.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Aug 6, 2025
…5637)

* otel: use receivertest to test fbreceiver

Use the receivertest.CheckConsumeContract to test filebeatreceiver. Requires
some piping to forward the unique test id attribute required by receivertest.

* add a mutex since Generate runs in parallel

* seems like returning an error in the output disables retries

* go mod tidy

* make notice

* fix otelconsumer tests to asser no error

* fix batch test

* revert otelconsumer error message

* let the testing pkg remove the file when the test ends

* go mod tidy

* add isReceiverTest property to otelconsumer

* fix typo

* add doc comment for TestConsumeContract

* rollback changes to go.mod and go.sum

* update NOTICE.txt

(cherry picked from commit ee17a83)

# Conflicts:
#	NOTICE.txt
#	go.mod
#	x-pack/filebeat/fbreceiver/receiver_test.go
#	x-pack/libbeat/outputs/otelconsumer/otelconsumer.go
mergify bot pushed a commit that referenced this pull request Aug 6, 2025
…5637)

* otel: use receivertest to test fbreceiver

Use the receivertest.CheckConsumeContract to test filebeatreceiver. Requires
some piping to forward the unique test id attribute required by receivertest.

* add a mutex since Generate runs in parallel

* seems like returning an error in the output disables retries

* go mod tidy

* make notice

* fix otelconsumer tests to asser no error

* fix batch test

* revert otelconsumer error message

* let the testing pkg remove the file when the test ends

* go mod tidy

* add isReceiverTest property to otelconsumer

* fix typo

* add doc comment for TestConsumeContract

* rollback changes to go.mod and go.sum

* update NOTICE.txt

(cherry picked from commit ee17a83)

# Conflicts:
#	NOTICE.txt
#	go.mod
mergify bot pushed a commit that referenced this pull request Aug 6, 2025
…5637)

* otel: use receivertest to test fbreceiver

Use the receivertest.CheckConsumeContract to test filebeatreceiver. Requires
some piping to forward the unique test id attribute required by receivertest.

* add a mutex since Generate runs in parallel

* seems like returning an error in the output disables retries

* go mod tidy

* make notice

* fix otelconsumer tests to asser no error

* fix batch test

* revert otelconsumer error message

* let the testing pkg remove the file when the test ends

* go mod tidy

* add isReceiverTest property to otelconsumer

* fix typo

* add doc comment for TestConsumeContract

* rollback changes to go.mod and go.sum

* update NOTICE.txt

(cherry picked from commit ee17a83)

# Conflicts:
#	NOTICE.txt
#	go.mod
mauri870 added a commit that referenced this pull request Aug 7, 2025
…ivertest test suite (#45774)

* otel: fix retries in otelconsumer and add receivertest test suite (#45637)

* otel: use receivertest to test fbreceiver

Use the receivertest.CheckConsumeContract to test filebeatreceiver. Requires
some piping to forward the unique test id attribute required by receivertest.

* add a mutex since Generate runs in parallel

* seems like returning an error in the output disables retries

* go mod tidy

* make notice

* fix otelconsumer tests to asser no error

* fix batch test

* revert otelconsumer error message

* let the testing pkg remove the file when the test ends

* go mod tidy

* add isReceiverTest property to otelconsumer

* fix typo

* add doc comment for TestConsumeContract

* rollback changes to go.mod and go.sum

* update NOTICE.txt

(cherry picked from commit ee17a83)

# Conflicts:
#	NOTICE.txt
#	go.mod

* fix conflicts

---------

Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
mauri870 added a commit that referenced this pull request Aug 7, 2025
…ivertest test suite (#45773)

* otel: fix retries in otelconsumer and add receivertest test suite (#45637)

* otel: use receivertest to test fbreceiver

Use the receivertest.CheckConsumeContract to test filebeatreceiver. Requires
some piping to forward the unique test id attribute required by receivertest.

* add a mutex since Generate runs in parallel

* seems like returning an error in the output disables retries

* go mod tidy

* make notice

* fix otelconsumer tests to asser no error

* fix batch test

* revert otelconsumer error message

* let the testing pkg remove the file when the test ends

* go mod tidy

* add isReceiverTest property to otelconsumer

* fix typo

* add doc comment for TestConsumeContract

* rollback changes to go.mod and go.sum

* update NOTICE.txt

(cherry picked from commit ee17a83)

# Conflicts:
#	NOTICE.txt
#	go.mod
#	x-pack/filebeat/fbreceiver/receiver_test.go
#	x-pack/libbeat/outputs/otelconsumer/otelconsumer.go

* fix conflicts

* remove unused code

---------

Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
kruskall pushed a commit to kruskall/beats that referenced this pull request Aug 7, 2025
…astic#45637)

* otel: use receivertest to test fbreceiver

Use the receivertest.CheckConsumeContract to test filebeatreceiver. Requires
some piping to forward the unique test id attribute required by receivertest.

* add a mutex since Generate runs in parallel

* seems like returning an error in the output disables retries

* go mod tidy

* make notice

* fix otelconsumer tests to asser no error

* fix batch test

* revert otelconsumer error message

* let the testing pkg remove the file when the test ends

* go mod tidy

* add isReceiverTest property to otelconsumer

* fix typo

* add doc comment for TestConsumeContract

* rollback changes to go.mod and go.sum

* update NOTICE.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.19 Automated backport to the 8.19 branch backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[beats receivers] otelconsumer returns an error on batch publish failure which disables retries Use receivertest package to test beats receivers
5 participants