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 SpiUtil to improve mocking #5679

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

jack-berg
Copy link
Member

Working on file configuration stuff, which will have to load SPI implementations like autoconfigure. We currently have most of our SPI related code in static methods in SpiUtil, which makes testing / mocking difficult.

This refactors the SPI accessors in an SpiHelper class. SpiHeler accepts a ClassLoader as an argument, and can be passed around autoconfigure (and soon file configuration interpretation code) in place of ClassLoader. It contains accessors for the various ways we load SPI implementations (named and configurable via ConfigProperties, orders, and a plain list).

Much better for mocking in tests.

This is a strict refactor.

@jack-berg jack-berg requested a review from a team August 3, 2023 20:30
@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Patch coverage: 97.36% and project coverage change: +0.01% 🎉

Comparison is base (90ab366) 91.31% compared to head (4be082b) 91.33%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5679      +/-   ##
============================================
+ Coverage     91.31%   91.33%   +0.01%     
- Complexity     4980     4989       +9     
============================================
  Files           554      554              
  Lines         14735    14769      +34     
  Branches       1376     1378       +2     
============================================
+ Hits          13456    13489      +33     
  Misses          883      883              
- Partials        396      397       +1     
Files Changed Coverage Δ
...ry/sdk/autoconfigure/internal/NamedSpiManager.java 100.00% <ø> (ø)
...nfigure/AutoConfiguredOpenTelemetrySdkBuilder.java 94.40% <85.71%> (ø)
.../autoconfigure/LogRecordExporterConfiguration.java 100.00% <100.00%> (ø)
...sdk/autoconfigure/LoggerProviderConfiguration.java 100.00% <100.00%> (ø)
.../sdk/autoconfigure/MeterProviderConfiguration.java 100.00% <100.00%> (ø)
...sdk/autoconfigure/MetricExporterConfiguration.java 100.00% <100.00%> (ø)
...try/sdk/autoconfigure/PropagatorConfiguration.java 100.00% <100.00%> (ø)
...metry/sdk/autoconfigure/ResourceConfiguration.java 94.73% <100.00%> (ø)
...y/sdk/autoconfigure/SpanExporterConfiguration.java 100.00% <100.00%> (ø)
...sdk/autoconfigure/TracerProviderConfiguration.java 100.00% <100.00%> (ø)
... and 1 more

... and 10 files with indirect coverage changes

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

Copy link
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

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

no objection from me

@jack-berg jack-berg merged commit 7eaffc8 into open-telemetry:main Aug 7, 2023
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.

3 participants