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

Calls to with_resource for signal builders (Metrics, Logs, Traces) are now additive #2677

Merged
merged 8 commits into from
Feb 20, 2025

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Feb 18, 2025

Fixes #2324

Changes

The calls to:

  • MeterProviderBuilder::with_resource
  • TracerProviderBuilder::with_resource
  • LoggerProviderBuilder::with_resource

Are now additive and the previous resource is not discarded anymore. Additionally, I fixed a bug where setting the schema_url was discarded due to a bug how merging of resources was handled.

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)

@martintmk martintmk requested a review from a team as a code owner February 18, 2025 08:33
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.2%. Comparing base (dc9a5c8) to head (374574c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2677     +/-   ##
=======================================
+ Coverage   79.1%   79.2%   +0.1%     
=======================================
  Files        122     122             
  Lines      22530   22621     +91     
=======================================
+ Hits       17839   17934     +95     
+ Misses      4691    4687      -4     

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

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

I agree with this change. Requesting changes to address below.

  1. [Feature]: add ability for with_resource to merge Resources on providers  #2324 (comment) - Check this and see if this makes sense, given there are more than one ideas suggested in the linked issue.
  2. Please make the change consistent across signals. (Okay to do that in separate PR to keep scope smaller)

@martintmk martintmk force-pushed the additive_with_resource branch from 2fa8aa0 to cfc37e6 Compare February 20, 2025 07:54
@martintmk martintmk changed the title Calls to MeterProviderBuilder::with_resource are now additive Calls to with_resource for signal builders (Metrics, Logs, Traces) are now additive Feb 20, 2025
@cijothomas
Copy link
Member

@martintmk Edited the PR Desc slightly to mark the associated issue to be resolved with this PR.
Nice work, thanks for exploring and weighing all options and driving closure!
(I removed "breaking" wording from changelog.)

@cijothomas cijothomas merged commit f01e8f4 into open-telemetry:main Feb 20, 2025
21 checks passed
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.

[Feature]: add ability for with_resource to merge Resources on providers
3 participants