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

Fix Resource dedup logic #1295

Closed
wants to merge 4 commits into from
Closed

Conversation

BrynCooke
Copy link
Contributor

Changes

Previously Resource would have last k,v wins when supplied a list of k,v even if it was empty.

This change brings the logic in line with the documentation on Resource::new and also applies the same to from_detectors.

Design

Suspect that the implementation was just an oversight as the existing doc comment seems to describe the desired behaviour.

Users will be able to specify a list of detectors in priority order and expect them to have first non empty value wins.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

Previously Resource would have last k,v wins when supplied a list of k,v even if it was empty.

This change brings the logic in line with the documentation on Resource::new and also applies the same to `from_detectors`.
@BrynCooke BrynCooke requested a review from a team October 12, 2023 20:24
@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

All modified lines are covered by tests ✅

Files Coverage Δ
opentelemetry-sdk/src/resource/mod.rs 98.7% <100.0%> (+0.2%) ⬆️

📢 Thoughts on this report? Let us know!.

lalitb
lalitb previously approved these changes Oct 13, 2023
opentelemetry-sdk/src/resource/mod.rs Outdated Show resolved Hide resolved
@hdost
Copy link
Contributor

hdost commented Oct 13, 2023

@BrynCooke thank you for your contribution. Unfortunately looking at the specs we should not even have an insert https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md

@BrynCooke
Copy link
Contributor Author

@hdost The insert method is private, it's not part of the public API, just to keep things dry.

@hdost
Copy link
Contributor

hdost commented Oct 13, 2023

@hdost The insert method is private, it's not part of the public API, just to keep things dry.

Indeed, however I do have one other issue as this works counter to the spec for merge.

The resulting resource MUST have all attributes that are on any of the two input resources. If a key exists on both the old and updating resource, the value of the updating resource MUST be picked (even if the updated value is empty).

@BrynCooke
Copy link
Contributor Author

BrynCooke commented Oct 13, 2023

Makes sense, I've instead raise an issue for discussion #1298 that hopefully captures the issues around the current behaviour. I'll leave this PR for you to close though.

@lalitb
Copy link
Member

lalitb commented Oct 13, 2023

Indeed, however I do have one other issue as this works counter to the spec for merge.

Good point.

@BrynCooke
Copy link
Contributor Author

Also from the spec:
| Resource detector packages MAY detect resource information from multiple possible sources and merge the result using the Merge operation described above.

So definitely agree that this PR doesn't fit the bill.

@lalitb lalitb dismissed their stale review October 13, 2023 12:44

deviates from merge logic

@BrynCooke BrynCooke closed this Oct 14, 2023
@BrynCooke BrynCooke deleted the resources branch October 19, 2023 11:56
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