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: remove the non-publishing packages from the npm workspace #1938

Merged
merged 24 commits into from
Feb 27, 2024

Conversation

trentm
Copy link
Contributor

@trentm trentm commented Feb 14, 2024

Because they cause difficulties with updating @opentelemetry/* dependencies.
This is "Option 3" from #1917

Refs: #1917

summary of changes

  • move all plugins/node/opentelemetry-instrumentation-FOO/examples/ to examples/FOO and fix up some details to get them working.
  • move packages/opentelemetry-sampler-aws-xray to incubator/opentelemetry-sampler-aws-xray/
  • These packages are now NOT included in the monorepo workspace.
  • Removed npm run compile:examples.
  • Removed entries for these packages from release-please config and manifest.

checklist (done)

  • Undo "option 1" work from chore: add non-releasing packages to release-please config so their local deps get bumped #1928
  • Q: is "incubator/" dir a reasonable name? Or put sampler-aws-xray in "archive/"?
  • move plugins/node/instr-FOO/examples to top-level examples/FOO dir. (Note that this reverses the intent from an effort 1-2y ago to move from examples/ to the instrumentation dirs.)
  • Try to confirm that my 'update-otel-deps.js' script now works better at updating deps in this repo.
  • manually test each of those examples
  • clean up intent in examples/README.md
  • start an issue for working through modernizing or dropping examples
  • document expectation/procedure for maintaining examples

Copy link

codecov bot commented Feb 14, 2024

Codecov Report

Merging #1938 (6db8f7b) into main (7d5cdb0) will decrease coverage by 0.02%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1938      +/-   ##
==========================================
- Coverage   91.04%   91.02%   -0.02%     
==========================================
  Files         147      146       -1     
  Lines        7530     7491      -39     
  Branches     1507     1501       -6     
==========================================
- Hits         6856     6819      -37     
+ Misses        674      672       -2     

see 1 file with indirect coverage changes

@pichlermarc
Copy link
Member

Q: is "incubator/" dir a reasonable name? Or put sampler-aws-xray in "archive/"?

I think so, yes :) I think it works better than archive and this should be a dir that we can easily re-name (since it's not released, there wouldn't be a lot of links pointing towards this)

move plugins/node/instr-FOO/examples to top-level examples/FOO dir. (Note that this reverses the intent from an effort 1-2y ago to move from examples/ to the instrumentation dirs.)

That's unfortunate, but I think it's fine. Up-to-date examples are important, but I'd put a higher priority on releasing on time.

@trentm
Copy link
Contributor Author

trentm commented Feb 21, 2024

Sorry for the delay. I'll get to this tomorrow (Wednesday).

'npm install --package-lock-only' did not accomplish this.
This regen was necessary because those vestigial entries caused
surprising breakage in some 'npm install --no-save ...' commands
such as TAV is doing. It broke TAV tests with [email protected].
@trentm
Copy link
Contributor Author

trentm commented Feb 22, 2024

Here is/was a nice surprise (sarcasm) with npm.

With the above changes the TAV (test-all-versions) tests were failing, but just with [email protected] (not with 4.17.0 and not with 4.17.2). What the TAV tests effectively do is: npm install --no-save mongodb@VERSION; npm test. Look at what was happening with that npm install --no-save ... attempt in the instrumentation-mongodb dir:

[~/tm/opentelemetry-js-contrib2/plugins/node/opentelemetry-instrumentation-mongodb (git:tm-1917-option-3)]
% npm ls mongodb
[email protected] /Users/trentm/tm/opentelemetry-js-contrib2
└─┬ @opentelemetry/[email protected] -> ./plugins/node/opentelemetry-instrumentation-mongodb
  └── [email protected]

[~/tm/opentelemetry-js-contrib2/plugins/node/opentelemetry-instrumentation-mongodb (git:tm-1917-option-3)]
% npm install --no-save [email protected]
...

[~/tm/opentelemetry-js-contrib2/plugins/node/opentelemetry-instrumentation-mongodb (git:tm-1917-option-3)]
% npm ls mongodb
[email protected] /Users/trentm/tm/opentelemetry-js-contrib2
└─┬ @opentelemetry/[email protected] -> ./plugins/node/opentelemetry-instrumentation-mongodb
  └── [email protected]

npm install exited successfully but it did NOT install the requested mongodb version in the current dir.

It took a while to notice that while I had removed the "plugins/node/opentelemetry-instrumentation-mongodb/examples" directory, the "package-lock.json" file still had that vestigial entry. Using npm install --package-lock-only did not remove these entries.

If I manually make this change to that vestigial entry:

% git diff -U15
diff --git a/package-lock.json b/package-lock.json
index 89c3fa77..94e12811 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -35060,32 +35060,31 @@
       }
     },
     "plugins/node/opentelemetry-instrumentation-mongodb/examples": {
       "name": "mongodb-example",
       "version": "0.28.0",
       "extraneous": true,
       "license": "Apache-2.0",
       "dependencies": {
         "@opentelemetry/api": "^1.0.0",
         "@opentelemetry/exporter-jaeger": "^1.0.0",
         "@opentelemetry/exporter-zipkin": "^1.0.0",
         "@opentelemetry/instrumentation": "^0.48.0",
         "@opentelemetry/instrumentation-http": "^0.48.0",
         "@opentelemetry/instrumentation-mongodb": "^0.32.0",
         "@opentelemetry/sdk-trace-base": "^1.0.0",
-        "@opentelemetry/sdk-trace-node": "^1.0.0",
-        "mongodb": "^3.6.11"
+        "@opentelemetry/sdk-trace-node": "^1.0.0"
       },
       "devDependencies": {
         "cross-env": "^7.0.3",
         "ts-node": "^10.6.0",
         "typescript": "4.4.4"
       },
       "engines": {
         "node": ">=8.12.0"
       }
     },
     "plugins/node/opentelemetry-instrumentation-mongodb/node_modules/bl": {
       "version": "2.2.1",
       "resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz",
       "integrity": "sha512-6Pesp1w0DEX1N550i/uGV/TqucVL4AM/pgThFSN/Qq9si1/DF9aIHs1BxD8V/QU0HoeHO6cQRTAuYnLPKq1e4g==",
       "dev": true,

Then it works:

% npm install --no-save [email protected] && npm ls mongodb
...

% npm ls mongodb
Run `npm audit` for details.
[email protected] /Users/trentm/tm/opentelemetry-js-contrib2
└─┬ @opentelemetry/[email protected] -> ./plugins/node/opentelemetry-instrumentation-mongodb
  └── [email protected] invalid: "3.6.11" from plugins/node/opentelemetry-instrumentation-mongodb

npm ERR! code ELSPROBLEMS
npm ERR! invalid: [email protected] /Users/trentm/tm/opentelemetry-js-contrib2/node_modules/mongodb

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/trentm/.npm/_logs/2024-02-22T19_29_22_304Z-debug-0.log

Basically I think there are at least a couple bugs in npm here:

  • npm install --package-lock-only does not remove vestigial workspace dir entries
  • That npm install --no-save ... should not exit successfully when it does not install the request mongodb version. BTW a contributing reason this only happened with [email protected] is because that exact version was installed at the top-level node_modules/mongodb because version 4.17.1 is a pinned dep of the version of mongoose installed by instrumentation-mongoose.

The only things I know to do here are:

  1. rm and re-create package-lock.json, or
  2. manually edit out those ".../examples" entries from package-lock.json

The latter seems fraught -- there is a possible whole dep tree that I don't
want to try to correctly clean up. So I did the former:

% rm package-lock.json
% npm install --package-lock-only
% git diff package-lock.json | wc -l
   51786

Sigh. The result is an inpenetrable 52k line diff. (IME, npm package-lock updates are unstable on whether some fields are included, e.g.: resolved, integrity, license. The package-lock stability could be because I'm jumping around on npm versions, but I'm not aware of docs here.)

We do see the removal of the vestigial ".../examples/" entries, e.g.:

-    "plugins/node/opentelemetry-instrumentation-mongodb/examples": {
-      "name": "mongodb-example",
-      "version": "0.28.0",
-      "extraneous": true,
-      "license": "Apache-2.0",
-      "dependencies": {
-        "@opentelemetry/api": "^1.0.0",
-        "@opentelemetry/exporter-jaeger": "^1.0.0",
-        "@opentelemetry/exporter-zipkin": "^1.0.0",
-        "@opentelemetry/instrumentation": "^0.48.0",
-        "@opentelemetry/instrumentation-http": "^0.48.0",
-        "@opentelemetry/instrumentation-mongodb": "^0.32.0",
-        "@opentelemetry/sdk-trace-base": "^1.0.0",
-        "@opentelemetry/sdk-trace-node": "^1.0.0",
-        "mongodb": "^3.6.11"
-      },
-      "devDependencies": {
-        "cross-env": "^7.0.3",
-        "ts-node": "^10.6.0",
-        "typescript": "4.4.4"
-      },
-      "engines": {
-        "node": ">=8.12.0"
-      }
-    },

@trentm trentm marked this pull request as ready for review February 22, 2024 20:08
@trentm trentm requested a review from a team February 22, 2024 20:08
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reviewer note: This change removes the non-publishing package entries that were added in #1939.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reviewer note: This diff makes it look like a total re-write, but I only changed the "Installation" section.

@@ -8,13 +8,12 @@
"zipkin:client": "cross-env EXPORTER=zipkin ts-node src/client.ts",
"jaeger:server": "cross-env EXPORTER=jaeger ts-node src/server.ts",
"jaeger:client": "cross-env EXPORTER=jaeger ts-node src/client.ts",
"compile": "tsc -p .",
"setup": "cd ../../../../ && npm ci && cd plugins/node/opentelemetry-instrumentation-express && npm run compile && cd examples && npm run compile"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reviewer note: (/cc @JamieDanielson) this "setup" script is no longer necessary. Now that the examples are not part of the workspace, the user just needs to npm install.

Copy link
Contributor Author

@trentm trentm Feb 22, 2024

Choose a reason for hiding this comment

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

reviewer note: Good luck reviewing this. :) Here is the most succinct version of the diff I could make: https://gist.github.com/trentm/92c639ca7cd86722268d4d4390cecea2

Copy link
Member

Choose a reason for hiding this comment

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

Any hand crafted changes in there or just what npm created?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just what npm created.

'undici-types', required by the version of @types/node used
by the new instrumentation-perf-hooks, was lost in the merge
from main.
@trentm
Copy link
Contributor Author

trentm commented Feb 24, 2024

"Unit Tests / unit-test (14) (pull_request) " failure

This is in the new instrumentation-perf-hooks:

> @opentelemetry/[email protected] test
> nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'



  nodejs.event_loop.utilization
    ✓ should stop exporting metrics when disabled
    ✓ should not export immediately after enable
    ✓ can use default eventLoopUtilizationMeasurementInterval
    1) should export event loop utilization metrics after eventLoopUtilizationMeasurementInterval


  3 passing (84ms)
  1 failing

  1) nodejs.event_loop.utilization
       should export event loop utilization metrics after eventLoopUtilizationMeasurementInterval:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

false !== true

      + expected - actual

      -false
      +true
      
      at Context.<anonymous> (test/event_loop_utilization.test.ts:94:12)
      at runNextTicks (internal/process/task_queues.js:60:5)
      at processTimers (internal/timers.js:497:9)

So I'm guessing that test is flaky. I have not repro'd locally yet.

@trentm
Copy link
Contributor Author

trentm commented Feb 25, 2024

So I'm guessing that test is flaky. I have not repro'd locally yet.

The test failure was on this line:

assert.strictEqual(metrics[0].dataPoints[0].value < 1, true);

So I wonder if the new nodejs.event_loop.utilization metric can unexpectedly be higher than 1. Bug in the math for that metric?

@pichlermarc pichlermarc merged commit d9af321 into open-telemetry:main Feb 27, 2024
17 checks passed
@trentm trentm deleted the tm-1917-option-3 branch February 27, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants