Skip to content

opentelemetry-sdk: align resource detector schema url conflict behavor with other languages - #5672

Open
herin049 wants to merge 7 commits into
open-telemetry:mainfrom
herin049:feat/detector-schema-url-conflict
Open

herin049 wants to merge 7 commits into
open-telemetry:mainfrom
herin049:feat/detector-schema-url-conflict

Conversation

@herin049

Copy link
Copy Markdown
Contributor

Description

This PR is related to the discussion in the 9/17/26 SIG call regarding handling merging of Resource objects with conflicting schema URLs. The behavior prior to this PR is to drop all attributes for new Resources while merging if the new Resource's schema URL is incompatible with the current Resource's schema URL. This PR updates the SDK's internal resource detector schema URL conflict behavior with other languages. That is, it simply logs a warning and permanently clears the schema URL.

Related to: #2688

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py314-test-opentelemetry-sdk

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@herin049
herin049 requested a review from a team as a code owner September 17, 2026 20:25
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-23 16:00 UTC

Review the latest changes.

Also blocked by: Merge conflicts.

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.

@JoeyPatricio JoeyPatricio left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Read through the merge logic and the tests. Behavior matches what Java and Go do on conflict (attributes merged, warning, schema_url cleared), with the addition that the cleared state is kept through later merges, which the description calls out. Test cases cover the conflict, the sticky case, and the aggregated-resources path. LGTM.

@herin049
herin049 requested a balanced review from Copilot September 19, 2026 03:26

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Equality and hashing omit behaviorally significant conflict state, and the central attribute-merging behavior lacks an independent test.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

Updates resource merging to retain attributes while permanently clearing conflicting schema URLs.

Changes:

  • Tracks schema URL conflicts across merges.
  • Logs conflicts as warnings and expands tests.
  • Adds a changelog entry.
File Description
resources/​__init__.py Implements conflict-aware merging.
test_resources.py Updates merge tests.
.changelog/​5672.added Documents the behavior change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py
Comment thread .changelog/5672.added Outdated
Comment thread opentelemetry-sdk/tests/resources/test_resources.py Outdated
@tammy-baylis-swi tammy-baylis-swi moved this to Ready for review in Python PR digest Sep 24, 2026

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

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

4 participants