Skip to content

Update the default resource to include telemetry.sdk entity - #8927

Open
jack-berg wants to merge 3 commits into
open-telemetry:mainfrom
jack-berg:default-resource-telemetry-entity
Open

jack-berg wants to merge 3 commits into
open-telemetry:mainfrom
jack-berg:default-resource-telemetry-entity

Conversation

@jack-berg

Copy link
Copy Markdown
Member

@jack-berg
jack-berg requested a review from a team as a code owner October 9, 2026 19:03
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on maintainers · refreshed 2026-11-25 18:32 UTC

Merge when ready.

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.
  • Should this be with the author? Comment /dashboard route:author to route it back.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.55%. Comparing base (70276b7) to head (311ae00).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8927      +/-   ##
============================================
- Coverage     90.55%   90.55%   -0.01%     
+ Complexity    11196    11194       -2     
============================================
  Files          1032     1032              
  Lines         30524    30526       +2     
  Branches       3999     3999              
============================================
+ Hits          27642    27643       +1     
+ Misses         1910     1909       -1     
- Partials        972      974       +2     

☔ 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.

@jkwatson jkwatson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude: automated review of this PR (AI-generated; please double-check).

Recommendation: Problems found: please look at the flagged points before merging.

Checked 8 points from the briefing: 5 verified, 3 flagged.

Verified

  • ✅ Merging with user resources (see sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java:383-409, sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java:885-902)
  • ✅ Constant relocation (see sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java:43-64, sdk/common/src/main/java/io/opentelemetry/sdk/common/internal/SemConvConstants.java:31-42)
  • ✅ Test expectations on entity ordering (see sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java:131, sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java:228)
  • ✅ Should the TODO to null the default schema URL be tracked in an issue, and what condition would let it be removed? (see sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java:61-64, sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java:229-247)
  • ✅ Why did SdkSpanBuilderTest change imports (U17, U18) and are they only needed for the toString change? (see sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanBuilderTest.java:38, sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanBuilderTest.java:48)

Flagged

  • ❌ Schema URL nulling on DEFAULT (inline comment)
  • ❓ Identity vs description split (inline comment)
  • ❌ Do exporters (e.g. OTLP) now emit entity_refs for telemetry.sdk by default, and is that intended for every default resource? (inline comment)

.build();

private static final Resource DEFAULT = MANDATORY.merge(TELEMETRY_SDK);
// TODO(jack-berg): Explicitly null out schema url to avoid avoid assigning schemaUrl to default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude: possible problem: Schema URL nulling on DEFAULT

The nulling works on DEFAULT itself. The attributes and the telemetry.sdk entity stay intact, the resource schemaUrl is null, and the entity keeps 1.40.0. Resource.merge() also behaves as before, because it uses buildWithSchemaUrl and a null base takes the other side's URL. The nulling does not survive toBuilder().build(): ResourceBuilder derives 1.40.0 from the single entity. So the common Resource.getDefault().toBuilder()...build() pattern now yields a resource with schemaUrl 1.40.0, which was null before. If that resource is later merged with a resource that has a different schemaUrl, the result is null and an info log is written. The PR's own test asserts this behavior. The TODO says the goal is to avoid assigning a schemaUrl, so the reviewer should decide whether this is acceptable or whether toBuilder() should pin a null URL.

Evidence:

  • sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java:61-69 DEFAULT is built with buildWithSchemaUrl(null), so the resource schemaUrl is null while the entity keeps 1.40.0.
  • sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java:283 build() derives the schema URL from the entities when none is set explicitly, so a single 1.40.0 entity gives 1.40.0.
  • sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java:270-278 toBuilder() copies a schemaUrl only if it is non-null, so a null one gets re-derived on build().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is the request to preserve a null resource schema URL through toBuilder().build()? The comment describes the behavior but leaves the proposed change unclear.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's more of a "is this intended or not" question, rather than a suggestion of a fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed the special nulling. It didn't survive rebuilding and made schema handling depend on the construction path. We already associate a schema url elsewhere we construct entity aware resources (e.g. ServiceInstanceIdResourceProvider and others) and I couldn't think of a good reason why the default reason would be different, especially given the fragility of whether or not its included post rebuilding. The default now carries 1.40.0 consistently. We accept normal schema-conflict behavior here: merging with another schema clears the resource-level URL but preserves attributes and entity schema URLs.

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.

3 participants