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(scripts): update-otel-deps.js script fixes #2520

Merged

Conversation

trentm
Copy link
Contributor

@trentm trentm commented Nov 7, 2024

  • Run 'npm install ...' task twice to update a local dep, which is sometimes necessary.
  • A start at fixes for working with [email protected]

some details

"scripts/update-otel-deps.js" goes through a lot of motions to attempt to properly update all @opentelemetry/* deps in the contrib repo. It is far from perfect. This PR deals with a couple issues.

Typically I've been running it with node v18.20.4, npm 10.7.0 and it typically works.

npm outdated -j ... format changes

In more recent version of npm, e.g. node v20.16.0 (npm v10.8.1), I noticed a crash in the script due to a change in the format. An example is shown here: https://gist.github.com/trentm/e67fb941a4aca339c2911d873b2e8ab6#gistcomment-5271177

This PR does the minimal change to work with that output.

(In separate work, it may now be possible to improve the script by using the "wanted" values from the new and better npm outdated -j output in newer npm versions. However, not for now.)

npm install ... needed twice sometimes

Back in the original motivating issue for this script I noted: #1917 (comment)

updating the @opentelemetry/contrib-test-utils dep in packages/opentelemetry-sampler-aws-xray requires running npm install twice:

...

There are changes to the package-lock.json in each of those npm install ... steps that I haven't shown.

I hit that issue again, this time with:

cd plugins/node/opentelemetry-instrumentation-aws-lambda && npm install @opentelemetry/[email protected]

My (only slightly educated) guess is that this can happen when the npm install ... is attempting to update a local dep -- i.e. a dep on a package that is another workspace in the same repo. In a follow-up comment on this PR I'll provide some details. Basically I think this is an npm bug. I've changed the script to run the npm install ... twice for these cases.

warning

I've found this script does not reliably work with the more recent npm version in Node v20: node v20.16.0 (npm v10.8.1).
The script does complete, but includes warning output pointing out that not all deps were updated, so it isn't a silent miss.

Fixing this is something that should be dug into later.

- Run 'npm install ...' task twice to update a local dep, which is sometimes necessary.
- A start at fixes for working with [email protected]
@trentm trentm requested a review from pichlermarc November 7, 2024 22:31
@trentm trentm self-assigned this Nov 7, 2024
@trentm trentm requested a review from a team as a code owner November 7, 2024 22:31
@trentm
Copy link
Contributor Author

trentm commented Nov 7, 2024

details on 'npm install ...' being needed twice

As mentioned above, I found that this needed to be run twice to completely update the dep:

cd plugins/node/opentelemetry-instrumentation-aws-lambda && npm install @opentelemetry/[email protected]

A first npm install:

$ cd plugins/node/opentelemetry-instrumentation-aws-lambda
$ npm install @opentelemetry/[email protected]

just removes this package-lock entry that is part of the handling of this 'npm install' command. Note that npm install ... exited with 0 (success) status.

diff --git a/package-lock.json b/package-lock.json
index 709d3366..afdb073f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -36975,21 +36975,6 @@
         "@opentelemetry/api": ">=1.0.0 <1.10.0"
       }
     },
-    "plugins/node/opentelemetry-instrumentation-aws-lambda/node_modules/@opentelemetry/propagator-aws-xray-lambda": {
-      "version": "0.52.1",
-      "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-aws-xray-lambda/-/propagator-aws-xray-lambda-0.52.1.tgz",
-      "integrity": "sha512-LBAu/1SRVuWrsWTzqUxZmzWinsS76UH/qApgYjmaN6Q8RcObXeZOmR0+FLSwkRX7OLGhLLQKiu3CQmlgXbpNCw==",
-      "dev": true,
-      "dependencies": {
-        "@opentelemetry/propagator-aws-xray": "1.25.1"
-      },
-      "engines": {
-        "node": ">=14"
-      },
-      "peerDependencies": {
-        "@opentelemetry/api": ">=1.3.0 <1.10.0"
-      }
-    },
     "plugins/node/opentelemetry-instrumentation-aws-lambda/node_modules/@types/node": {
       "version": "18.18.14",
       "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz",

At this point the "plugins/node/opentelemetry-instrumentation-aws-lambda/package.json" still has "@opentelemetry/propagator-aws-xray-lambda": "^0.52.1", in "devDependencies".

Running a second time:

$ npm install @opentelemetry/[email protected]

and now all the necessary updates are done:

diff --git a/package-lock.json b/package-lock.json
index 709d3366..b0229864 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -36919,7 +36919,7 @@
         "@opentelemetry/api": "^1.3.0",
         "@opentelemetry/core": "^1.8.0",
         "@opentelemetry/propagator-aws-xray": "^1.25.1",
-        "@opentelemetry/propagator-aws-xray-lambda": "^0.52.1",
+        "@opentelemetry/propagator-aws-xray-lambda": "^0.53.0",
         "@opentelemetry/sdk-metrics": "^1.8.0",
         "@opentelemetry/sdk-trace-base": "^1.8.0",
         "@opentelemetry/sdk-trace-node": "^1.8.0",
@@ -36975,21 +36975,6 @@
         "@opentelemetry/api": ">=1.0.0 <1.10.0"
       }
     },
-    "plugins/node/opentelemetry-instrumentation-aws-lambda/node_modules/@opentelemetry/propagator-aws-xray-lambda": {
-      "version": "0.52.1",
-      "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-aws-xray-lambda/-/propagator-aws-xray-lambda-0.52.1.tgz",
-      "integrity": "sha512-LBAu/1SRVuWrsWTzqUxZmzWinsS76UH/qApgYjmaN6Q8RcObXeZOmR0+FLSwkRX7OLGhLLQKiu3CQmlgXbpNCw==",
-      "dev": true,
-      "dependencies": {
-        "@opentelemetry/propagator-aws-xray": "1.25.1"
-      },
-      "engines": {
-        "node": ">=14"
-      },
-      "peerDependencies": {
-        "@opentelemetry/api": ">=1.3.0 <1.10.0"
-      }
-    },
     "plugins/node/opentelemetry-instrumentation-aws-lambda/node_modules/@types/node": {
       "version": "18.18.14",
       "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz",
@@ -47476,7 +47461,7 @@
         "@opentelemetry/core": "^1.8.0",
         "@opentelemetry/instrumentation": "^0.54.0",
         "@opentelemetry/propagator-aws-xray": "^1.25.1",
-        "@opentelemetry/propagator-aws-xray-lambda": "^0.52.1",
+        "@opentelemetry/propagator-aws-xray-lambda": "^0.53.0",
         "@opentelemetry/sdk-metrics": "^1.8.0",
         "@opentelemetry/sdk-trace-base": "^1.8.0",
         "@opentelemetry/sdk-trace-node": "^1.8.0",
@@ -47515,15 +47500,6 @@
             "@opentelemetry/core": "1.25.1"
           }
         },
-        "@opentelemetry/propagator-aws-xray-lambda": {
-          "version": "0.52.1",
-          "resolved": "https://registry.npmjs.org/@opentelemetry/propagator-aws-xray-lambda/-/propagator-aws-xray-lambda-0.52.1.tgz",
-          "integrity": "sha512-LBAu/1SRVuWrsWTzqUxZmzWinsS76UH/qApgYjmaN6Q8RcObXeZOmR0+FLSwkRX7OLGhLLQKiu3CQmlgXbpNCw==",
-          "dev": true,
-          "requires": {
-            "@opentelemetry/propagator-aws-xray": "1.25.1"
-          }
-        },
         "@types/node": {
           "version": "18.18.14",
           "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz",
diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json b/plugins/node/opentelemetry-instrumentation-aws-lambda/pac
kage.json
index 5fbf0899..6df797e2 100644
--- a/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json
+++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json
@@ -45,7 +45,7 @@
     "@opentelemetry/api": "^1.3.0",
     "@opentelemetry/core": "^1.8.0",
     "@opentelemetry/propagator-aws-xray": "^1.25.1",
-    "@opentelemetry/propagator-aws-xray-lambda": "^0.52.1",
+    "@opentelemetry/propagator-aws-xray-lambda": "^0.53.0",
     "@opentelemetry/sdk-metrics": "^1.8.0",
     "@opentelemetry/sdk-trace-base": "^1.8.0",
     "@opentelemetry/sdk-trace-node": "^1.8.0",

This has to be an npm bug. I ran out of energy putting together a possible repro to open an npm issue.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.80%. Comparing base (acbaf20) to head (0dd5eff).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2520      +/-   ##
==========================================
+ Coverage   90.75%   90.80%   +0.04%     
==========================================
  Files         169      169              
  Lines        8018     8018              
  Branches     1632     1632              
==========================================
+ Hits         7277     7281       +4     
+ Misses        741      737       -4     

see 1 file with indirect coverage changes

trentm added a commit to trentm/opentelemetry-js-contrib that referenced this pull request Nov 7, 2024
This uses update-otel-deps.js fixes from open-telemetry#2520.

    0.52.1 -> 0.53.0 @opentelemetry/propagator-aws-xray-lambda (range-bump) (local)
    0.54.0 -> 0.54.2 @opentelemetry/api-logs
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation-fetch
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation-grpc
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation-http
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation-xml-http-request
    0.54.0 -> 0.54.2 @opentelemetry/otlp-transformer
    0.54.0 -> 0.54.2 @opentelemetry/sdk-logs
    0.54.0 -> 0.54.2 @opentelemetry/sdk-node
    1.25.1 -> 1.27.0 @opentelemetry/core
    1.25.1 -> 1.26.0 @opentelemetry/propagator-aws-xray (local)
    1.25.1 -> 1.27.0 @opentelemetry/semantic-conventions

Refs: open-telemetry#2520
@trentm
Copy link
Contributor Author

trentm commented Nov 7, 2024

Mostly as a note to myself, here is the complete successful run of scripts/update-otel-deps.js:

% node --version
v18.20.4

% npm --version
10.7.0

% npm ci 

% ./scripts/update-otel-deps.js
Updating deps matching "@opentelemetry/*" in 64 workspace dirs

Gathering info on outdated deps in each workspace:
 - packages/winston-transport (1 of 64)
 - packages/opentelemetry-test-utils (2 of 64)
 - packages/opentelemetry-sql-common (3 of 64)
 - packages/opentelemetry-redis-common (4 of 64)
 - packages/opentelemetry-propagation-utils (5 of 64)
 - packages/opentelemetry-id-generator-aws-xray (6 of 64)
 - packages/opentelemetry-host-metrics (7 of 64)
 - packages/baggage-span-processor (8 of 64)
 - plugins/node/opentelemetry-instrumentation-winston (9 of 64)
 - plugins/node/opentelemetry-instrumentation-router (10 of 64)
 - plugins/node/opentelemetry-instrumentation-restify (11 of 64)
 - plugins/node/opentelemetry-instrumentation-redis-4 (12 of 64)
 - plugins/node/opentelemetry-instrumentation-redis (13 of 64)
 - plugins/node/opentelemetry-instrumentation-pino (14 of 64)
 - plugins/node/opentelemetry-instrumentation-pg (15 of 64)
 - plugins/node/opentelemetry-instrumentation-net (16 of 64)
 - plugins/node/opentelemetry-instrumentation-nestjs-core (17 of 64)
 - plugins/node/opentelemetry-instrumentation-mysql2 (18 of 64)
 - plugins/node/opentelemetry-instrumentation-mysql (19 of 64)
 - plugins/node/opentelemetry-instrumentation-mongodb (20 of 64)
 - plugins/node/opentelemetry-instrumentation-memcached (21 of 64)
 - plugins/node/opentelemetry-instrumentation-koa (22 of 64)
 - plugins/node/opentelemetry-instrumentation-knex (23 of 64)
 - plugins/node/opentelemetry-instrumentation-ioredis (24 of 64)
 - plugins/node/opentelemetry-instrumentation-hapi (25 of 64)
 - plugins/node/opentelemetry-instrumentation-graphql (26 of 64)
 - plugins/node/opentelemetry-instrumentation-generic-pool (27 of 64)
 - plugins/node/opentelemetry-instrumentation-fastify (28 of 64)
 - plugins/node/opentelemetry-instrumentation-express (29 of 64)
 - plugins/node/opentelemetry-instrumentation-dns (30 of 64)
 - plugins/node/opentelemetry-instrumentation-connect (31 of 64)
 - plugins/node/opentelemetry-instrumentation-cassandra (32 of 64)
 - plugins/node/opentelemetry-instrumentation-bunyan (33 of 64)
 - plugins/node/opentelemetry-instrumentation-aws-sdk (34 of 64)
 - plugins/node/opentelemetry-instrumentation-aws-lambda (35 of 64)
 - plugins/node/instrumentation-undici (36 of 64)
 - plugins/node/instrumentation-tedious (37 of 64)
 - plugins/node/instrumentation-socket.io (38 of 64)
 - plugins/node/instrumentation-runtime-node (39 of 64)
 - plugins/node/instrumentation-mongoose (40 of 64)
 - plugins/node/instrumentation-lru-memoizer (41 of 64)
 - plugins/node/instrumentation-kafkajs (42 of 64)
 - plugins/node/instrumentation-fs (43 of 64)
 - plugins/node/instrumentation-dataloader (44 of 64)
 - plugins/node/instrumentation-cucumber (45 of 64)
 - plugins/node/instrumentation-amqplib (46 of 64)
 - plugins/web/opentelemetry-plugin-react-load (47 of 64)
 - plugins/web/opentelemetry-instrumentation-user-interaction (48 of 64)
 - plugins/web/opentelemetry-instrumentation-long-task (49 of 64)
 - plugins/web/opentelemetry-instrumentation-document-load (50 of 64)
 - propagators/propagator-aws-xray-lambda (51 of 64)
 - propagators/propagator-aws-xray (52 of 64)
 - propagators/opentelemetry-propagator-ot-trace (53 of 64)
 - propagators/opentelemetry-propagator-instana (54 of 64)
 - detectors/node/opentelemetry-resource-detector-instana (55 of 64)
 - detectors/node/opentelemetry-resource-detector-github (56 of 64)
 - detectors/node/opentelemetry-resource-detector-gcp (57 of 64)
 - detectors/node/opentelemetry-resource-detector-container (58 of 64)
 - detectors/node/opentelemetry-resource-detector-azure (59 of 64)
 - detectors/node/opentelemetry-resource-detector-aws (60 of 64)
 - detectors/node/opentelemetry-resource-detector-alibaba-cloud (61 of 64)
 - metapackages/auto-instrumentations-web (62 of 64)
 - metapackages/auto-instrumentations-node (63 of 64)
 - metapackages/auto-configuration-propagators (64 of 64)

Performing updates (2 `npm install ...`s, 1 `npm update ...`):
 $ cd plugins/node/opentelemetry-instrumentation-aws-lambda && npm install @opentelemetry/[email protected]
 $ cd plugins/node/opentelemetry-instrumentation-aws-lambda && npm install @opentelemetry/[email protected] # second time because "npm install"ing a *local* dep can take two tries
 $ npm update @opentelemetry/api-logs @opentelemetry/instrumentation @opentelemetry/otlp-transformer @opentelemetry/sdk-node @opentelemetry/instrumentation-http @opentelemetry/sdk-logs @opentelemetry/semantic-conventions @opentelemetry/core @opentelemetry/propagator-aws-xray @opentelemetry/instrumentation-xml-http-request @opentelemetry/instrumentation-fetch @opentelemetry/instrumentation-grpc @opentelemetry/exporter-logs-otlp-proto @opentelemetry/exporter-logs-otlp-http @opentelemetry/exporter-trace-otlp-proto @opentelemetry/exporter-trace-otlp-grpc @opentelemetry/exporter-logs-otlp-grpc @opentelemetry/exporter-trace-otlp-http @opentelemetry/otlp-grpc-exporter-base @opentelemetry/otlp-exporter-base

Sanity check that all matching packages are up-to-date:
 $ npm outdated @opentelemetry/api-logs @opentelemetry/core @opentelemetry/exporter-jaeger @opentelemetry/instrumentation @opentelemetry/otlp-transformer @opentelemetry/resources @opentelemetry/sdk-metrics @opentelemetry/sdk-node @opentelemetry/sdk-trace-base @opentelemetry/sdk-trace-node @opentelemetry/semantic-conventions @opentelemetry/api @opentelemetry/contrib-test-utils @opentelemetry/context-async-hooks @opentelemetry/winston-transport @opentelemetry/redis-common @opentelemetry/sql-common @opentelemetry/instrumentation-http @opentelemetry/sdk-logs @opentelemetry/propagation-utils @opentelemetry/propagator-aws-xray @opentelemetry/propagator-aws-xray-lambda @opentelemetry/propagator-b3 @opentelemetry/sdk-trace-web @opentelemetry/context-zone-peer-dep @opentelemetry/instrumentation-xml-http-request @opentelemetry/instrumentation-fs @opentelemetry/instrumentation-document-load @opentelemetry/instrumentation-fetch @opentelemetry/instrumentation-user-interaction @opentelemetry/instrumentation-amqplib @opentelemetry/instrumentation-aws-lambda @opentelemetry/instrumentation-aws-sdk @opentelemetry/instrumentation-bunyan @opentelemetry/instrumentation-cassandra-driver @opentelemetry/instrumentation-connect @opentelemetry/instrumentation-cucumber @opentelemetry/instrumentation-dataloader @opentelemetry/instrumentation-dns @opentelemetry/instrumentation-express @opentelemetry/instrumentation-fastify @opentelemetry/instrumentation-generic-pool @opentelemetry/instrumentation-graphql @opentelemetry/instrumentation-grpc @opentelemetry/instrumentation-hapi @opentelemetry/instrumentation-ioredis @opentelemetry/instrumentation-kafkajs @opentelemetry/instrumentation-knex @opentelemetry/instrumentation-koa @opentelemetry/instrumentation-lru-memoizer @opentelemetry/instrumentation-memcached @opentelemetry/instrumentation-mongodb @opentelemetry/instrumentation-mongoose @opentelemetry/instrumentation-mysql @opentelemetry/instrumentation-mysql2 @opentelemetry/instrumentation-nestjs-core @opentelemetry/instrumentation-net @opentelemetry/instrumentation-pg @opentelemetry/instrumentation-pino @opentelemetry/instrumentation-redis @opentelemetry/instrumentation-redis-4 @opentelemetry/instrumentation-restify @opentelemetry/instrumentation-router @opentelemetry/instrumentation-socket.io @opentelemetry/instrumentation-tedious @opentelemetry/instrumentation-undici @opentelemetry/instrumentation-winston @opentelemetry/resource-detector-alibaba-cloud @opentelemetry/resource-detector-aws @opentelemetry/resource-detector-azure @opentelemetry/resource-detector-container @opentelemetry/resource-detector-gcp @opentelemetry/propagator-jaeger @opentelemetry/propagator-ot-trace

Summary of changes (possible commit message):
--
chore(deps): update deps matching "@opentelemetry/*"

    0.52.1 -> 0.53.0 @opentelemetry/propagator-aws-xray-lambda (range-bump) (local)
    0.54.0 -> 0.54.2 @opentelemetry/api-logs
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation-fetch
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation-grpc
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation-http
    0.54.0 -> 0.54.2 @opentelemetry/instrumentation-xml-http-request
    0.54.0 -> 0.54.2 @opentelemetry/otlp-transformer
    0.54.0 -> 0.54.2 @opentelemetry/sdk-logs
    0.54.0 -> 0.54.2 @opentelemetry/sdk-node
    1.25.1 -> 1.27.0 @opentelemetry/core
    1.25.1 -> 1.26.0 @opentelemetry/propagator-aws-xray (local)
    1.25.1 -> 1.27.0 @opentelemetry/semantic-conventions
--

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Thanks for updating the script 🙂
Edit: and thanks for the detailed explanations - they are very helpful when trying to understand what's going on 🙂

@pichlermarc pichlermarc merged commit 7cc26fb into open-telemetry:main Nov 8, 2024
11 checks passed
@trentm trentm deleted the tm-improve-update-otel-deps-script branch November 8, 2024 19:21
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.

2 participants