Skip to content

Break sdk incubator dependency on autoconfigure#8242

Open
jack-berg wants to merge 4 commits intoopen-telemetry:mainfrom
jack-berg:break-incubator-autoconfigure-dependency
Open

Break sdk incubator dependency on autoconfigure#8242
jack-berg wants to merge 4 commits intoopen-telemetry:mainfrom
jack-berg:break-incubator-autoconfigure-dependency

Conversation

@jack-berg
Copy link
Copy Markdown
Member

Related to #7292

Right now declarative config in the opentelemetry-sdk-extension-incubator module depends on autoconfigure for a few key bits of functionality:

  • SpiHelper, for ordered loading utlities, AutoConfigureListener state management
  • ResourceConfiguration to leverage the autoconfigure logic for parsing otel.service.attributes, which is reused to handle .resource.attributes_list

These dependencies require autoconfigure to load file config via reflection in order to avoid a circular dependency. Ultimately, we want some sort of dedicated config module, with autoconfigure having a dependency on it. This requires we break the incubator -> autoconfigure dependency, which is what this PR does.

Changes:

  • Add new ComponentLoader#loadList utility method to load SPI to a list intead of iterable. We do this in a number of places so just add a utility method to make it more convenient.
  • Add new Ordered#loadOrderedList utlity method. This logic was in SpiHelper, but doing it in multiple places suggests extracting a utility method.
  • Remove all declarative config references to SpiHelper, instead performing the state management directly within DeclarativeConfigContext. SpiHlper really ought to be named AutoConfigureContext, but will save that for a future work.
  • Replace autoconfigure reflective access to declarative config with compileOnly dependency
    • One thing that was tricky here was how to get the declarative config resource. Currently, we reflectively access via DeclarativeConfigContext, but we're trying to get rid of this reflection and continuing to use DeclarativeConfigContext would negate or require a broader refactor to make DeclarativeConfigContext internal / public. I ended up solving this by accessing the resource reflectively from SdkMeterProvider.
  • Add a gradle task to copy the autoconfigure otel.resource.attributes parsing logic to declarative config. This allows the code to be reused without having to move to a central public location like opentelemetry-sdk-common, and without having to manually synchronize the content.
  • Tweak tests to reflect changes

@jack-berg jack-berg requested a review from a team as a code owner April 1, 2026 21:59
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 93.96552% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.30%. Comparing base (2682f15) to head (46d9956).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...pentelemetry/sdk/autoconfigure/IncubatingUtil.java 71.42% 5 Missing and 1 partial ⚠️
...lemetry/sdk/autoconfigure/EnvironmentResource.java 96.29% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8242      +/-   ##
============================================
- Coverage     90.32%   90.30%   -0.03%     
+ Complexity     7654     7650       -4     
============================================
  Files           843      844       +1     
  Lines         23080    23076       -4     
  Branches       2312     2310       -2     
============================================
- Hits          20848    20838      -10     
- Misses         1516     1521       +5     
- Partials        716      717       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant