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): make properties for async resource resolution optional #3677

Merged

Conversation

pichlermarc
Copy link
Member

@pichlermarc pichlermarc commented Mar 15, 2023

Which problem is this PR solving?

See #3676, existing detectors that previously worked with 1.9.1 do not compile anymore. This PR fixes this, but will break the use of resource.waitForAsyncAttributes() that was introduced in the most recent version. Looks like this is the only way to restore compatibility. I'm open to any suggestions to improve this.

Fixes #3676
Fixes open-telemetry/opentelemetry-js-contrib#1429

Short description of the changes

  • make properties for async resource resolution optional

Type of change

  • Bug fix, restoring backwards compatibility, see semver:

    What do I do if I accidentally release a backwards incompatible change as a minor version?

    As soon as you realize that you’ve broken the Semantic Versioning spec, fix the problem and release a new minor version that corrects the problem and restores backwards compatibility. Even under this circumstance, it is unacceptable to modify versioned releases. If it’s appropriate, document the offending version and inform your users of the problem so that they are aware of the offending version.

How Has This Been Tested?

  • Existing tests
  • Added an unmodified 1.9.1-style Detector as a regression test that should fail compilation when incompatible changes are made in the future.

Checklist:

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

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #3677 (0794001) into main (3653f5c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 0794001 differs from pull request most recent head c4b75ec. Consider uploading reports for the commit c4b75ec to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3677   +/-   ##
=======================================
  Coverage   93.70%   93.70%           
=======================================
  Files         277      277           
  Lines        8451     8454    +3     
  Branches     1755     1761    +6     
=======================================
+ Hits         7919     7922    +3     
  Misses        532      532           
Impacted Files Coverage Δ
packages/opentelemetry-resources/src/Resource.ts 100.00% <100.00%> (ø)
...y-sdk-trace-base/src/export/SimpleSpanProcessor.ts 92.10% <100.00%> (+0.67%) ⬆️

@pichlermarc pichlermarc marked this pull request as ready for review March 15, 2023 11:49
@pichlermarc pichlermarc requested a review from a team as a code owner March 15, 2023 11:49
@Flarna
Copy link
Member

Flarna commented Mar 15, 2023

What about the existing compat tests here?

Are they still needed/helpful?
And why haven't they shown the compat problems or do they focus on something completely different?

@dyladan
Copy link
Member

dyladan commented Mar 15, 2023

Those tests focus on using the old version of @opentelemetry/resources with a new resource detector. I believe what marc here is showing is the opposite? Using an old detector with the newest version of @opentelemetry/resources

@pichlermarc
Copy link
Member Author

Exactly, they're the other way around. Even without the ts-ignore that I removed in 0887706, this would not have been caught using the existing tests.

@dyladan
Copy link
Member

dyladan commented Mar 15, 2023

So what happened is that we added a new method to the Resource class which doesn't exist in resources used by old resource detectors

@dyladan
Copy link
Member

dyladan commented Mar 15, 2023

This is only a problem because the old detect method referenced the class Resource instead of a Resource interface. Yet again concrete class references in types coming to bite us.

https://github.com/open-telemetry/opentelemetry-js/blob/v1.9.1/packages/opentelemetry-resources/src/types.ts#L33

@dyladan
Copy link
Member

dyladan commented Mar 15, 2023

Discussed in SIG. We decided that the breaking change introduced in 1.10.0 was itself a bug. This PR fixes that break and is itself a bugfix and NOT a break. Even though it is technically "breaking" from 1.10.0, it is compatible with 1.9.x and previous versions.

/cc @open-telemetry/javascript-approvers @open-telemetry/javascript-maintainers for visibility on this decision

@dyladan
Copy link
Member

dyladan commented Mar 15, 2023

@pichlermarc i'm going to leave this until tomorrow before merge/release just to be sure people have the chance to see the decision above. Since the bug only affects people who implement their own resource detectors and the fix is easy for those people to unblock themselves if they need I think this isn't the biggest rush bug.

@dyladan dyladan merged commit 9a37faf into open-telemetry:main Mar 16, 2023
@dyladan dyladan deleted the fix/breaking-resources branch March 16, 2023 12:38
dyladan added a commit to dyladan/opentelemetry-js that referenced this pull request Mar 16, 2023
…open-telemetry#3677)

* fix(resource): make properties for async resolution optional

* fix(changelog): add changelog

* fix(resources): add regression test

* fix(resources): remove ts-ignore in tests

---------

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
@dyladan dyladan mentioned this pull request Mar 16, 2023
dyladan added a commit that referenced this pull request Mar 20, 2023
* fix(resource): make properties for async resource resolution optional (#3677)

* fix(resource): make properties for async resolution optional

* fix(changelog): add changelog

* fix(resources): add regression test

* fix(resources): remove ts-ignore in tests

---------

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>

* Changelog

* Bump patch versions

* fix(resources): change fs/promises import to be node 12 compatible (#3681)

* fix(resources): change fs/promises import to be node 12 compatible

* fix(changelog): add changelog entry.

---------

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants