Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(batchprocessor): Multi/single-shard consistent start method and field names #11314

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented Sep 30, 2024

Description

There are two implementations of the batcher interface with several inconsistencies. Notably, the single-shard case would start a goroutine before Start() is called, which can be confusing when the goroutine leak checker notices it. This makes the single-shard batcher wait until Start() to create its single shard. A confusing field name batcher in this case becomes single, and a new field is added for use in start named processor to create the new shard.

For the multi-shard batcher, start() does nothing, but this structure confusingly embeds the batchProcessor. Rename the field processor for consistency with the single-shard case.

Link to tracking issue

Part of #11308.

@jmacd jmacd requested a review from a team as a code owner September 30, 2024 23:04
@jmacd jmacd requested a review from songy23 September 30, 2024 23:04
@jmacd jmacd added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Sep 30, 2024
Copy link

codecov bot commented Sep 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.44%. Comparing base (98230db) to head (f1eba61).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11314   +/-   ##
=======================================
  Coverage   91.43%   91.44%           
=======================================
  Files         424      424           
  Lines       20264    20270    +6     
=======================================
+ Hits        18529    18535    +6     
  Misses       1359     1359           
  Partials      376      376           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bogdandrutu bogdandrutu merged commit dd054f1 into open-telemetry:main Oct 1, 2024
49 checks passed
@github-actions github-actions bot added this to the next release milestone Oct 1, 2024
jackgopack4 pushed a commit to jackgopack4/opentelemetry-collector that referenced this pull request Oct 8, 2024
…d names (open-telemetry#11314)

#### Description
There are two implementations of the `batcher` interface with several
inconsistencies. Notably, the single-shard case would start a goroutine
before `Start()` is called, which can be confusing when the goroutine
leak checker notices it. This makes the single-shard batcher wait until
Start() to create its single shard. A confusing field name `batcher` in
this case becomes `single`, and a new field is added for use in start
named `processor` to create the new shard.

For the multi-shard batcher, `start()` does nothing, but this structure
confusingly embeds the batchProcessor. Rename the field `processor` for
consistency with the single-shard case.

#### Link to tracking issue
Part of open-telemetry#11308.
bogdandrutu pushed a commit that referenced this pull request Nov 4, 2024
…or (#11594)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

The single-shard batcher is currently created and started in the start
function. If the consume function is called before the start function,
sb.single will be nil and it will panic. I'm not sure if that can happen
in the Otel collector but it might happen in distributions that have a
different runtime (such as Alloy - Grafana's distribution).

I think that conceptually, it's better to create the shard in the
constructor and start it in the start function.

PS: I did not create an entry in the changelog because the initial
[PR](#11314)
for this change didn't but let me know if I should add one.

Credits also to @thampiotr for this fix
djaglowski pushed a commit to djaglowski/opentelemetry-collector that referenced this pull request Nov 21, 2024
…or (open-telemetry#11594)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

The single-shard batcher is currently created and started in the start
function. If the consume function is called before the start function,
sb.single will be nil and it will panic. I'm not sure if that can happen
in the Otel collector but it might happen in distributions that have a
different runtime (such as Alloy - Grafana's distribution).

I think that conceptually, it's better to create the shard in the
constructor and start it in the start function.

PS: I did not create an entry in the changelog because the initial
[PR](open-telemetry#11314)
for this change didn't but let me know if I should add one.

Credits also to @thampiotr for this fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants