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

chore(deps): replace semver with compare-versions to reduce bundle size #4170

Closed
wants to merge 5 commits into from

Conversation

Ankcorn
Copy link

@Ankcorn Ankcorn commented Sep 28, 2023

Which problem is this PR solving?

Semver makes up 1/4 of the output of our bundled opentelemetry distribution whilst not providing much utility.

In aws-lambda environments, this contributes significantly to the coldstart (about 30ms)

image

Fixes # (issue)
#3537

Short description of the changes

replaces semver with compare-versions in

  • instrumentation-http
  • instrumentation
  • sdk-base-node

The API should be comparable and behaviour should be very similar.

With the changes in instrumentation, the prerelease flag is no longer needed because this is a default of the satisfies method is not broken by prerelease tags

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Checklist:

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

@Ankcorn Ankcorn requested a review from a team September 28, 2023 17:24
@Ankcorn
Copy link
Author

Ankcorn commented Sep 28, 2023

Also any advice on the best ways to test this, I have sanity-checked the compare-versions methods and confirmed they behave the same way as semver. The unit tests pass (also helped catch a bug 🥳) anything else needed?

@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

Merging #4170 (e74634f) into main (52f428a) will decrease coverage by 1.99%.
Report is 1 commits behind head on main.
The diff coverage is n/a.

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

@@            Coverage Diff             @@
##             main    #4170      +/-   ##
==========================================
- Coverage   92.50%   90.52%   -1.99%     
==========================================
  Files         275      159     -116     
  Lines        7369     3757    -3612     
  Branches     1540      835     -705     
==========================================
- Hits         6817     3401    -3416     
+ Misses        552      356     -196     

see 187 files with indirect coverage changes

): boolean {
if (typeof version === 'undefined') {
// If we don't have the version, accept the wildcard case only
return supportedVersions.includes('*');
}

return supportedVersions.some(supportedVersion => {
return satisfies(version, supportedVersion, { includePrerelease });
return supportedVersion === '*' || satisfies(version, supportedVersion);
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, looks like this is not the same behavior anymore. In the gRPC instrumentation, we set the supported version to 1.*, but this now evaluates to false with any 1.x.x version (which is why the tests fail).

Copy link
Member

Choose a reason for hiding this comment

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

this may affect lot's of third-party instrumentations and instrumentations over at https://github.com/open-telemetry/opentelemetry-js-contrib

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

@Ankcorn Ankcorn Sep 29, 2023

Choose a reason for hiding this comment

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

Hey, currently looking at this! Thanks for creating that issue :)

I see a few community packages doing this too

This package also just specifies 1 as the version?

Copy link
Author

Choose a reason for hiding this comment

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

I tested out adding a ^ in front of the version in the instrumentation-grpc package and that does seem to resolve this issue but I have listened to too many of Linus's rants to think shipping this satisfies behaviour change as it stands is a good idea 😆

Copy link
Author

Choose a reason for hiding this comment

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

I have opened a PR to fix this on compare-versions omichelsen/compare-versions#71

I will see where we get too

Copy link

github-actions bot commented Dec 4, 2023

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Dec 4, 2023
Copy link

This PR was closed because it has been stale for 14 days with no activity.

@github-actions github-actions bot closed this Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants