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

[chore] Nit-fix exporter.request.MergeSplit() #12016

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

sfc-gh-sili
Copy link
Contributor

@sfc-gh-sili sfc-gh-sili commented Jan 5, 2025

Description

This PR fixes how capacityLimit is updated in exporter.request.MergeSplit().

Before

		if srcReq.ld.LogRecordCount() <= capacityLeft {
			if destReq == nil {
				destReq = srcReq
			} else {
				srcReq.ld.ResourceLogs().MoveAndAppendTo(destReq.ld.ResourceLogs())
			}
			capacityLeft -= destReq.ld.LogRecordCount()
			continue
		}

After

		srcCount := srcReq.ld.LogRecordCount()
		if srcCount <= capacityLeft {
			if destReq == nil {
				destReq = srcReq
			} else {
				srcReq.ld.ResourceLogs().MoveAndAppendTo(destReq.ld.ResourceLogs())
			}
			capacityLeft -= srcCount
			continue
		}

With that said, the original implementation does not cause any bug because "the larger for loop" loops through only two items. In the first loop, destReq is guaranteed to be nil, so capacityLeft is updated properly. In the second loop, we jump out of the loop immediately so the accuracy of capacityLeft does not matter any more.

Link to tracking issue

NA

Testing

NA

Documentation

NA

@sfc-gh-sili sfc-gh-sili marked this pull request as draft January 5, 2025 00:42
@sfc-gh-sili sfc-gh-sili changed the title refactor request batch [chore] Refactor exporter.request.MergeSplit() Jan 5, 2025
Copy link

codecov bot commented Jan 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.70%. Comparing base (e5e12bf) to head (0974ea4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12016   +/-   ##
=======================================
  Coverage   91.70%   91.70%           
=======================================
  Files         447      447           
  Lines       23728    23732    +4     
=======================================
+ Hits        21759    21763    +4     
  Misses       1600     1600           
  Partials      369      369           

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

@sfc-gh-sili sfc-gh-sili changed the title [chore] Refactor exporter.request.MergeSplit() [chore] Nit-fix exporter.request.MergeSplit() Jan 5, 2025
@sfc-gh-sili sfc-gh-sili marked this pull request as ready for review January 5, 2025 01:03
@bogdandrutu bogdandrutu added this pull request to the merge queue Jan 5, 2025
Merged via the queue into open-telemetry:main with commit 57c6c15 Jan 5, 2025
54 of 69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants