Skip to content

[stanza] Remove unnecessary slice allocation to track errors (even nil) #39367

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

Merged
merged 1 commit into from
Apr 13, 2025

Conversation

bogdandrutu
Copy link
Member

The most inefficient usages are in ProcessBatch and ProcessBatchWith, where we allocate a slice of errors even if return value is nil.

Changed all usages to make sure we don't repeat that mistake and establish a healthier pattern.

Comment on lines +81 to +86
var errs error
for i := range entries {
errs = append(errs, process(ctx, entries[i]))
errs = multierr.Append(errs, process(ctx, entries[i]))
}
return errors.Join(errs...)
return errs
Copy link
Member Author

Choose a reason for hiding this comment

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

This caused an unnecessary slice allocation.

@djaglowski
Copy link
Member

LGTM in principle. Please address CI failures.

@bogdandrutu bogdandrutu merged commit 35f141b into open-telemetry:main Apr 13, 2025
171 checks passed
@bogdandrutu bogdandrutu deleted the stanza-error branch April 13, 2025 21:11
@github-actions github-actions bot added this to the next release milestone Apr 13, 2025
akshays-19 pushed a commit to akshays-19/opentelemetry-collector-contrib that referenced this pull request Apr 23, 2025
…l) (open-telemetry#39367)

The most inefficient usages are in ProcessBatch and ProcessBatchWith,
where we allocate a slice of errors even if return value is nil.

Changed all usages to make sure we don't repeat that mistake and
establish a healthier pattern.

Signed-off-by: Bogdan Drutu <[email protected]>
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this pull request Apr 24, 2025
…l) (open-telemetry#39367)

The most inefficient usages are in ProcessBatch and ProcessBatchWith,
where we allocate a slice of errors even if return value is nil.

Changed all usages to make sure we don't repeat that mistake and
establish a healthier pattern.

Signed-off-by: Bogdan Drutu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants