Skip to content

Attach SdkResourceProvider in autoconfigure and declarative config - #9060

Draft
rooks-ns wants to merge 1 commit into
open-telemetry:mainfrom
rooks-ns:feat/attach-sdk-resource-provider
Draft

rooks-ns wants to merge 1 commit into
open-telemetry:mainfrom
rooks-ns:feat/attach-sdk-resource-provider

Conversation

@rooks-ns

Copy link
Copy Markdown
Contributor

Description

Implements follow-up 1 from #8865 by attaching SdkResourceProvider to SdkMeterProvider, SdkLoggerProvider, and SdkTracerProvider instead of a static Resource.

Changes

  • Declarative Config: Attaches the resolved SdkResourceProvider via Sdk*ProviderUtil.setSdkResourceProvider(...) across all signal builders.
  • Autoconfigure & Builders: Adds package-private setDefaultSdkResourceProvider to SdkTracerProviderBuilder, SdkMeterProviderBuilder, and SdkLoggerProviderBuilder. Autoconfigure supplies the baseline provider without tripping the strict IllegalStateException guard if a user customizer subsequently overrides or merges resources via .setResource(...) or .addResource(...).
  • Guard Integrity: Direct, explicit calls to setSdkResourceProvider continue to fail-fast against conflicting setResource/addResource invocations.
  • Tests: Added coverage for default provider delegation, customizer overrides, and cross-signal provider sharing.

Update autoconfigure and declarative configuration to attach a shared
SdkResourceProvider to SdkTracerProvider, SdkMeterProvider, and
SdkLoggerProvider instead of a static Resource.

- In declarative config, use Sdk*ProviderUtil.setSdkResourceProvider to
  attach the provider built from the resolved resource model.
- In autoconfigure, introduce and use setDefaultSdkResourceProvider on the
  signal provider builders to set the baseline resource provider while
  allowing signal-specific customizers to override or merge resources via
  setResource or addResource without throwing IllegalStateException.
- Preserve fail-fast guards when setSdkResourceProvider and
  setResource/addResource are explicitly configured on the same builder.
- Add unit tests verifying default provider usage, customizer overrides,
  and cross-signal provider sharing.
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-24 23:28 UTC

Move out of draft to request review.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.75000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.54%. Comparing base (4ce8c01) to head (a01ffca).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
...metry/sdk/logs/internal/SdkLoggerProviderUtil.java 75.00% 2 Missing ⚠️
...try/sdk/metrics/internal/SdkMeterProviderUtil.java 75.00% 2 Missing ⚠️
...etry/sdk/trace/internal/SdkTracerProviderUtil.java 75.00% 2 Missing ⚠️
...entelemetry/sdk/logs/SdkLoggerProviderBuilder.java 91.66% 0 Missing and 1 partial ⚠️
...telemetry/sdk/metrics/SdkMeterProviderBuilder.java 91.66% 0 Missing and 1 partial ⚠️
...ntelemetry/sdk/trace/SdkTracerProviderBuilder.java 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9060      +/-   ##
============================================
+ Coverage     90.45%   90.54%   +0.08%     
- Complexity    11179    11204      +25     
============================================
  Files          1032     1032              
  Lines         30500    30572      +72     
  Branches       3991     4005      +14     
============================================
+ Hits          27590    27681      +91     
+ Misses         1935     1915      -20     
- Partials        975      976       +1     

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
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