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

refactor(sdk-trace-base): remove _registeredSpanProcessors from BasicTracerProvider #5177

Merged

Conversation

david-luna
Copy link
Contributor

Which problem is this PR solving?

After merging #5152 it is not necessary to have _registeredSpanProcessors private property to modify at runtime. This PR does remove the property and adapts the tests.

Fixes #5136

Short description of the changes

  • remove _registeredSpanProcessors from BasicTracerProvider
  • wrap all processors in a MultiSpanProcessor to make sure forceFlush works in all situations.
  • add a test for it
  • update tests to not access the removed property

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • compiled all packages
  • tested all packages

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added

@david-luna david-luna requested a review from a team as a code owner November 19, 2024 14:45
@david-luna david-luna changed the title refactor(sdk-trace-base)!: remove _registeredSpanProcessors from BasicTracerProvider refactor(sdk-trace-base): remove _registeredSpanProcessors from BasicTracerProvider Nov 19, 2024
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.14%. Comparing base (4a394cc) to head (75b0843).
Report is 3 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5177      +/-   ##
==========================================
- Coverage   93.15%   93.14%   -0.02%     
==========================================
  Files         315      315              
  Lines        8113     8106       -7     
  Branches     1633     1633              
==========================================
- Hits         7558     7550       -8     
- Misses        555      556       +1     
Files with missing lines Coverage Δ
...elemetry-sdk-trace-base/src/BasicTracerProvider.ts 96.33% <100.00%> (+0.64%) ⬆️
packages/opentelemetry-sdk-trace-base/src/Span.ts 97.61% <ø> (ø)

... and 1 file with indirect coverage changes

---- 🚨 Try these New Features:

@@ -97,10 +97,8 @@ export class SpanImpl implements Span {
private readonly _startTimeProvided: boolean;

/**
* Constructs a new Span instance.
*
* @deprecated calling Span constructor directly is not supported. Please use tracer.startSpan.
Copy link
Contributor Author

@david-luna david-luna Nov 19, 2024

Choose a reason for hiding this comment

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

note to reviewer: this is a leftover from #5048. The class is now internal and used in Tracer

}

this.activeSpanProcessor = new MultiSpanProcessor(spanProcessors);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note to reviewer: forceFlush method was only iterating over the _registeredSpanProcessors. So when using the default exporter and processor (the else case) the BatchSpanProcessor.forceFlush method was never called. I've added a test for it

@@ -779,6 +834,29 @@ describe('BasicTracerProvider', () => {
});

describe('.forceFlush()', () => {
it('should call forceFlush with the default processor', done => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note for reviewer: this is the test to check that with exporter/processor defined from env the forceFlush method is called.

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

looks good, thank you 🙌

@pichlermarc pichlermarc merged commit f3a6310 into open-telemetry:next Nov 21, 2024
18 checks passed
@david-luna david-luna deleted the remove-registered-span-processors branch November 21, 2024 13:37
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