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

add internal method ToCollection() to Batch #3219

Closed
wants to merge 5 commits into from
Closed

add internal method ToCollection() to Batch #3219

wants to merge 5 commits into from

Conversation

TimothyMothra
Copy link
Contributor

@TimothyMothra TimothyMothra commented Apr 21, 2022

related to #2361.
pulling a minor change out of #3198.

Changes

  • Add internal method ToCollection to Batch

Please provide a brief description of the changes here.

This change is to eliminate the foreach boilerplate code:

foreach (var data in batch)
{
    someCollection.Add(data);
}

For significant contributions please make sure you have completed the following items:

  • Appropriate CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

Other options considered

  1. do nothing
    this will cause unit tests to have a lot of foreach statements.

  2. ToCollection(ICollection<T> someCollection)
    I considered this but decided to imitate Enumerable.ToList which returns the collection.

  3. ToList()
    I don't have a strong opinion about the return type. I chose to return ICollection because I see this used more often in this repo.

  4. add extension method/class to OpenTelemetry.Tests.Shared
    this would work, but is an extra file that would need to be imported into test projects.
    having this method in the Batch class allows it to access private fields.

@TimothyMothra TimothyMothra requested a review from a team April 21, 2022 19:03
Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

Doesn't seem to have a good reason to expose new public API from Batch.

@codecov
Copy link

codecov bot commented Apr 21, 2022

Codecov Report

Merging #3219 (d8deca4) into main (1918e4b) will decrease coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3219      +/-   ##
==========================================
- Coverage   85.69%   85.53%   -0.16%     
==========================================
  Files         260      260              
  Lines        9366     9367       +1     
==========================================
- Hits         8026     8012      -14     
- Misses       1340     1355      +15     
Impacted Files Coverage Δ
src/OpenTelemetry/Batch.cs 98.92% <100.00%> (+0.01%) ⬆️
...entation/ExportClient/OtlpGrpcTraceExportClient.cs 50.00% <0.00%> (-28.58%) ⬇️
...xporter.OpenTelemetryProtocol/OtlpTraceExporter.cs 59.09% <0.00%> (-18.19%) ⬇️
...ter.ZPages/Implementation/ZPagesActivityTracker.cs 97.14% <0.00%> (-2.86%) ⬇️
...metryProtocol/Implementation/ActivityExtensions.cs 88.73% <0.00%> (-2.71%) ⬇️
...nTelemetry/Internal/OpenTelemetrySdkEventSource.cs 73.27% <0.00%> (-0.87%) ⬇️
...ZPages/Implementation/ZPagesExporterEventSource.cs 62.50% <0.00%> (+6.25%) ⬆️

@TimothyMothra TimothyMothra changed the title add method ToCollection() to Batch add internal method ToCollection() to Batch Apr 21, 2022
@TimothyMothra
Copy link
Contributor Author

Doesn't seem to have a good reason to expose new public API from Batch.

changed to internal.
Verified that the tests that need this already have access to internals.

@TimothyMothra TimothyMothra deleted the 2361_batch branch December 8, 2022 22:30
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