Skip to content

Conversation

@jsumners-nr
Copy link
Contributor

This PR resolves #3575.

@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

❌ Patch coverage is 94.78673% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.12%. Comparing base (bc1faf3) to head (48a1c71).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
lib/subscribers/resolve-package-version.js 88.09% 10 Missing ⚠️
lib/subscribers/dc-base.js 97.87% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (bc1faf3) and HEAD (48a1c71). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (bc1faf3) HEAD (48a1c71)
unit-tests-22.x 1 0
integration-tests-esm-22.x 1 0
integration-tests-cjs-22.x 1 0
versioned-tests-22.x 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3626       +/-   ##
===========================================
- Coverage   97.84%   81.12%   -16.72%     
===========================================
  Files         440      429       -11     
  Lines       57644    56363     -1281     
  Branches        1        1               
===========================================
- Hits        56404    45727    -10677     
- Misses       1240    10636     +9396     
Flag Coverage Δ
integration-tests-cjs-22.x ?
integration-tests-esm-20.x 52.61% <54.50%> (-0.05%) ⬇️
integration-tests-esm-22.x ?
unit-tests-22.x ?
versioned-tests-20.x 81.02% <94.78%> (?)
versioned-tests-22.x ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jsumners-nr jsumners-nr marked this pull request as ready for review December 29, 2025 18:18
@jsumners-nr jsumners-nr force-pushed the issue-3575 branch 2 times, most recently from e6f19e0 to a76cd7f Compare January 6, 2026 15:04
@bizob2828 bizob2828 self-assigned this Jan 7, 2026
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

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

a coupe questions/comments. You're going to also have to remove the tracking of OnRequire metrics for subscribers. This is done here. Also you'll have a bunch of failing versioned tests as we have 1 per library to assert the previous OnRequire metrics, those will need to be updated and in all cases, rewritten as the previous metrics got incremented when a package was required. Now they aren't incremented until a method on the package is used

*
* @returns {string} The version string from the package manifest or "unknown".
*/
function resolveModuleVersion(moduleSpecifier, {
Copy link
Member

Choose a reason for hiding this comment

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

we have a very similar function in lib/util/get-package-version.js. you could pass off to use that for consistency after you get the base dir. If not, I'd still recommend setting the version to process.version if package.json cannot be found for consistency with that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a rather big difference between the implementations. The function in this PR:

  1. Starts from the directory that the module specifier resolves to. So for require('foo'), it'll start at /path/to/app/node_modules/foo/.
  2. If a manifest cannot be found there, it traverses up the tree one directory
  3. Repeat looking for a manifest
  4. Repeat until we hit the app root / do not find a manifest

The function in lib/util/ simply looks in the provided directory and returns the Node.js version if a manifest is not found there.

Do you think we will ever have a subscriber that targets a specifier like moduleName/sub/module.js that would mean we need the tree traversal algorithm in this PR's version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bizob2828 this implementation has changed a bit. Please re-review it.

@jsumners-nr jsumners-nr force-pushed the issue-3575 branch 2 times, most recently from edbaf16 to 6daf011 Compare January 9, 2026 19:41
@jsumners-nr jsumners-nr force-pushed the issue-3575 branch 2 times, most recently from fb3097d to b3cba72 Compare January 14, 2026 20:37
@jsumners-nr jsumners-nr requested a review from bizob2828 January 16, 2026 14:02
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

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

very close. a few comments. Nice creativity on trying to obtain the appropriate path of the module

bizob2828
bizob2828 previously approved these changes Jan 16, 2026
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

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

great work on this one 🚢 🇮🇹 . Also, don't forget to update angler with all the lovely updates for this one

@jsumners-nr jsumners-nr merged commit 5796574 into newrelic:main Jan 16, 2026
23 checks passed
@github-project-automation github-project-automation bot moved this from Needs PR Review to Done: Issues recently completed in Node.js Engineering Board Jan 16, 2026
@jsumners-nr jsumners-nr deleted the issue-3575 branch January 16, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done: Issues recently completed

Development

Successfully merging this pull request may close these issues.

Update how instrumentation is tracked for subscribers

2 participants