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

updating @opentelemetry/* deps is currently problematic #1917

Closed
trentm opened this issue Jan 31, 2024 · 13 comments · Fixed by #1928
Closed

updating @opentelemetry/* deps is currently problematic #1917

trentm opened this issue Jan 31, 2024 · 13 comments · Fixed by #1928
Assignees

Comments

@trentm
Copy link
Contributor

trentm commented Jan 31, 2024

Updating @opentelemetry/* deps in the contrib repo is currently problematic.
There are two kinds of updates here:

  1. Updating @opentelemetry/* deps that come from the core-repo (opentelemetry-js.git). This is typically done in a PR created after a release of packages from the core repo. In the past this was done via renovatebot, but since the switch to npm workspaces this has been problematic.
  2. Updating @opentelemetry/* deps that live in this same contrib-repo (internal deps). For example some packages depend on @opentelemetry/contrib-test-utils for testing; @opentelemetry/auto-instrumentations-node depends on all the instrumentation-* deps that live in this repo. This update is typically done by a release PR (handled via the release-please tool).

problems

The initial motivating problem was that attempts by renovatebot to do an update of OTel deps from the core repo was failing to update everything. For example, an attempt to update deps to versions 0.47.0/1.20.0 would leave parts of the contrib repo with deps at 1.19.0. Mixed 1.19.0 and 1.20.0 deps would cause breakages, e.g. type mismatches. See #1905 and then the follow-up #1906.

However, there are other issues, that I think stem from related causes.
Here are two examples of current silly/problematic behaviour.

First, updating the @opentelemetry/instrumentation-bunyan dep in its "examples/" package crashes npm.
In a clone of the contrib repo at the current "main" (commit 497a3c3):

[17:44:12 trentm@pink:~/src/opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-bunyan/examples (git:main)]
% npm outdated
Package                                Current  Wanted  Latest  Location                                                                                              Depended by
@opentelemetry/instrumentation-bunyan   0.34.1  0.34.1  0.35.0  plugins/node/opentelemetry-instrumentation-bunyan/node_modules/@opentelemetry/instrumentation-bunyan  examples@npm:[email protected]

[17:44:18 trentm@pink:~/src/opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-bunyan/examples (git:main rv:1)]
% npm install @opentelemetry/[email protected]
npm ERR! Cannot read properties of null (reading 'isDescendantOf')

npm ERR! A complete log of this run can be found in: /Users/trentm/.npm/_logs/2024-01-31T01_44_31_212Z-debug-0.log

(That npm log file is here: https://gist.github.com/trentm/c75060cfe647c6a3070fca1b1b589eec
It crashes with npm v10 -- included in Node v18.19.0 -- as well.)

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

[trentm@pink:~/src/opentelemetry-js-contrib/packages/opentelemetry-sampler-aws-xray (git:main)]
% npm outdated @opentelemetry/contrib-test-utils
Package                            Current  Wanted  Latest  Location                                                                                Depended by
@opentelemetry/contrib-test-utils   0.35.1  0.35.1  0.36.0  packages/opentelemetry-sampler-aws-xray/node_modules/@opentelemetry/contrib-test-utils  opentelemetry-sampler-aws-xray@npm:@opentelemetry/[email protected]

% grep test-utils package.json
    "@opentelemetry/contrib-test-utils": "^0.35.0",

% npm install @opentelemetry/[email protected]
...
% grep test-utils package.json
    "@opentelemetry/contrib-test-utils": "^0.35.1",

% npm install @opentelemetry/[email protected]
...
% grep test-utils package.json
    "@opentelemetry/contrib-test-utils": "^0.36.0",

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

Both of these problems make scripting the update of OTel deps difficult.

causes

The two silly cases above ultimately are probably npm bugs.
However, there are two complicating factors in the contrib repo:

  1. There are some workspace packages that aren't updating internal dependencies.

    • "packages/opentelemetry-sampler-aws-xray" depends on @opentelemetry/contrib-test-utils, but because the package isn't currently being released, it isn't part of the release-please PR that updates internal deps.
    • "plugins/node/*/examples/package.json" depend on contrib-repo packages (e.g. the instr-express/examples/ depend on @opentelemetry/instrumentation-express). These examples packages are not published, so they are currently not part of the release-please PR that updates internal deps.

    The result is that contrib-repo package versions move on (e.g. @opentelemetry/[email protected] is released), but the dep ranges in these non-publishing packages get stuck at an older version (e.g. bunyan example's dep is stuck at "^0.34.0"). The transitive deps of @opentelemetry/[email protected] are to older core-repo versions, but the direct core-repo deps in bunyan examples are updated to the latest: resulting in conflicting versions of deps.

  2. The "plugins/node/*/examples/package.json" packages are part of the npm workspace, but they have another workspace package in a parent dir. For example both "plugins/node/opentelemetry-instrumentation-bunyan" and its subdir "plugins/node/opentelemetry-instrumentation-bunyan/examples" are workspace packages. My guess is that npm just isn't well-tested for this case. When determining the node_modules/ tree layout, it needs to handle the case of the examples/ dir "seeing" the parent dir's node_modules/.... The result is some surprising, to me, layouts and the npm crash shown above.

options

1. Update the internal @opentelemetry/* even for the non-publishing packages.

This would mean that a release PR that bumps the express instrumentation should also update the examples/package.json, e.g.:

diff --git a/plugins/node/opentelemetry-instrumentation-express/examples/package.json b/plugins/node/opentelemetry-instrumentation-express/examples/package.json
index ff8807f4..ab5af50d 100644
--- a/plugins/node/opentelemetry-instrumentation-express/examples/package.json
+++ b/plugins/node/opentelemetry-instrumentation-express/examples/package.json
@@ -36,7 +36,7 @@
    "@opentelemetry/exporter-trace-otlp-proto": "^0.48.0",
    "@opentelemetry/exporter-zipkin": "^1.18.1",
    "@opentelemetry/instrumentation": "^0.48.0",
-    "@opentelemetry/instrumentation-express": "^0.34.1",
+    "@opentelemetry/instrumentation-express": "^0.35.0",
    "@opentelemetry/instrumentation-http": "^0.48.0",
    "@opentelemetry/resources": "^1.18.1",
    "@opentelemetry/sdk-trace-base": "^1.18.1",

This might just require adding the "sampler-aws-xray" and "*/examples/" dirs to "release-please-config.json", but I'm not sure if release-please will then attempt to npm publish these private packages or have other issues.

2. Less tightly specify contrib-repo deps in the non-publishing packages.

E.g.:

diff --git a/plugins/node/opentelemetry-instrumentation-express/examples/package.json b/plugins/node/opentelemetry-instrumentation-express/examples/package.json
index ff8807f4..09dc58c1 100644
--- a/plugins/node/opentelemetry-instrumentation-express/examples/package.json
+++ b/plugins/node/opentelemetry-instrumentation-express/examples/package.json
@@ -36,7 +36,7 @@
    "@opentelemetry/exporter-trace-otlp-proto": "^0.48.0",
    "@opentelemetry/exporter-zipkin": "^1.18.1",
    "@opentelemetry/instrumentation": "^0.48.0",
-    "@opentelemetry/instrumentation-express": "^0.34.1",
+    "@opentelemetry/instrumentation-express": "*",   // or "0.x" or similar
    "@opentelemetry/instrumentation-http": "^0.48.0",
    "@opentelemetry/resources": "^1.18.1",
    "@opentelemetry/sdk-trace-base": "^1.18.1",

This would result in the "sampler-aws-xray" and "examples/" packages always using the latest internal deps.

3. Remove the non-publishing packages from the npm workspace

E.g. this patch would do it for the "examples/" dirs, but not for the "sampler-aws-xray" package:

diff --git a/package.json b/package.json
index 53dd98d5..aa081f95 100644
--- a/package.json
+++ b/package.json
@@ -71,9 +71,7 @@
   "workspaces": [
     "packages/*",
     "plugins/node/*",
-    "plugins/node/*/examples",
     "plugins/web/*",
-    "plugins/web/*/examples",
     "propagators/*",
     "detectors/node/*",
     "metapackages/*"

This would take them out of the package-lock.json file and decouple them from releases and updates. It would take separate work to keep those package deps up to date (which could separately use dependabot/renovate).

For better or worse, this would mean that examples/ packages would not use the instrumentation code in the parent dir.

questions

Q1: @pichlermarc, do you know if adding these non-publishing packages to the release-please config would work as we want: update the internal deps, but still not published them?

Q2: Does anyone have opinions on the options above, or options I've missed?

@trentm trentm self-assigned this Jan 31, 2024
@Flarna
Copy link
Member

Flarna commented Jan 31, 2024

-    "@opentelemetry/instrumentation-express": "^0.34.1",
+    "@opentelemetry/instrumentation-express": "*",   // or "0.x" or similar

Not sure if this can work because the minor version part is seen a major from semver point of view for pre 1.0.0 version. Therefore such a range might pull in breaking changes.

Regarding non published packages:
I know that examples are important for users and everyone wishes a good documentations with perfect, easy to understand samples. But actually it seems we don't have the bandwidth here to create and maintain them. There are no tests for the existing examples (besides build) therefore noone knows if they still work/are up do date.
Besides that examples for individual instrumentation are not the helpful in real world scenarios.

From my point of view it's better to remove them to streamline the work on the productive code. Maybe we could refer to some bigger, even non JS specific OTel showcase somewhere instead?
Or maybe create a dedicated samples repo which is maintained/tested separate if there are people which would like to do this?

@pichlermarc
Copy link
Member

Q1: @pichlermarc, do you know if adding these non-publishing packages to the release-please config would work as we want: update the internal deps, but still not published them?

I think the answer is yes, if we ensure that the packages are set to private. Also we're publishing to the @opentelemetry namespace on npm so if we ensure that the namespace is different. It'll still create releases for the package though, not sure if there's a way to turn that off.

I know that examples are important for users and everyone wishes a good documentations with perfect, easy to understand samples. But actually it seems we don't have the bandwidth here to create and maintain them. There are no tests for the existing examples (besides build) therefore noone knows if they still work/are up do date.
Besides that examples for individual instrumentation are not the helpful in real world scenarios.

I agree with Flarna here, it's something we should consider.

Q2: Does anyone have opinions on the options above, or options I've missed?

I need to try something first, but I think I have another option that we could consider. I'll report back here with my findings.

@trentm
Copy link
Contributor Author

trentm commented Jan 31, 2024

-    "@opentelemetry/instrumentation-express": "^0.34.1",
+    "@opentelemetry/instrumentation-express": "*",   // or "0.x" or similar

Not sure if this can work because the minor version part is seen a major from semver point of view for pre 1.0.0 version. Therefore such a range might pull in breaking changes.

With this option I'm saying that the intent would be to say "this unpublished examples/ package is meant to work with the current version of instrumentation-express in this monorepo, whatever that version is". I.e. intentionally accepting that that might mean breaking changes. By using "0.x" (instead of "*") this could be limited to "... up until instrumentation-express hits 1.0.0".


Another option is to not have the "examples/package.json". So if a given instrumentation wants to have some examples, then it can, but not as a separate package. If it needs deps for the examples, it can add them to "devDependencies" of the parent instrumentation package.

I know that examples are important for users and everyone wishes a good documentations with perfect, easy to understand samples. But actually it seems we don't have the bandwidth here to create and maintain them.

I don't have a strong opinion either way on the examples. I agree most of them are out of date. The express and fastify examples were updated in the last few weeks. As a total guess: I think most of them will work just fine if their 0.x OTel deps are updated.

Even if examples are dropped, there is still the separate packages/opentelemetry-sampler-aws-xray to discuss.

@pichlermarc
Copy link
Member

pichlermarc commented Feb 5, 2024

Q2: Does anyone have opinions on the options above, or options I've missed?

I don't think there are any other options. 😬 Everything I've tried turned out to be a dead end. 😞

IMO we should go with Option 1:

It's possible to turn off GitHub releases for certain packages, which we can do via skip-github-release, like so:

"packages/sampler-aws-xray": { "skip-github-release": true },

This way we can skip the GitHub release and tagging in release please.

The docs for it say that we'll still need to tag it ourselves when using skip-github-release, but I think it's a non-issue. It needs the tag to determine what the last release was. If there isn't a last release, it will take all commits into consideration, which if fine for us as that would be exactly what we want when we first release it. If we never release the package that's also fine. release-please will do extra work, but it'll not interfere with anything.

This way:

  • it won't release the package (it's set to private in package.json)
  • we keep the GitHub releases free of any not-actually-released packages

We can likely do the same with the examples. Any examples that make our lives difficult beyond this point, we can archive to examples/ in the repository root directory (not linked to any workspace).

@trentm
Copy link
Contributor Author

trentm commented Feb 7, 2024

#1928 is an attempt at Option 1.

trentm added a commit to elastic/elastic-otel-node that referenced this issue Feb 9, 2024
…opentelemetry/* deps

The motivation here was that dependabot doesn't handle this group update for
a repo using npm workspaces (see #58
and experiences with opentelemetry-js-contrib, open-telemetry/opentelemetry-js-contrib#1917)
trentm added a commit to elastic/elastic-otel-node that referenced this issue Feb 12, 2024
…opentelemetry/* deps (#68)

The motivation here was that dependabot doesn't handle this group update for
a repo using npm workspaces (see #58
and experiences with opentelemetry-js-contrib, open-telemetry/opentelemetry-js-contrib#1917)
pichlermarc pushed a commit that referenced this issue Feb 13, 2024
…ocal deps get bumped (#1928)

* chore: add unreleasing packages to release-please config so their local deps get bumped

This is option 1 from #1917.

Refs: #1917

* drop commented out debug output
@JamieDanielson
Copy link
Member

I realize this issue is closed but mentioning here as promised on the release PR.

We might have to go with Option 3 after all, though I've missed the detail around the aws sampler package and suspect that makes it a trickier option.

@trentm trentm reopened this Feb 13, 2024
@trentm
Copy link
Contributor Author

trentm commented Feb 13, 2024

Re-opening. I thikn this is still open for discussion.

@Flarna
Copy link
Member

Flarna commented Feb 14, 2024

Maybe we should move the aws xray sampler into archive folder? Or into a in-development folder?

@trentm
Copy link
Contributor Author

trentm commented Feb 14, 2024

Or into a in-development folder?

Yah, I was working on a quick PR for discussion doing Option 3. Part of it moved sampler-aws-xray to an "incubator/" dir. I don't have a strong opinion on what directory name to use. I don't know if the existing "archive/" dir is appropriate for sampler-aws-xray?

@Flarna
Copy link
Member

Flarna commented Feb 14, 2024

I think archive is the wrong place. It holds modules published before with no maintainer but compatibility issues.
aws xray sampler was never published but has an active maintainer.

trentm added a commit to trentm/opentelemetry-js-contrib that referenced this issue Feb 14, 2024
Because they cause difficulties with updating `@opentelemetry/*` dependencies.
This is "Option 3" from open-telemetry#1917

Refs: open-telemetry#1917
trentm added a commit to trentm/opentelemetry-js-contrib that referenced this issue Feb 14, 2024
@trentm
Copy link
Contributor Author

trentm commented Feb 14, 2024

#1938 is a draft PR (still incomplete) doing Option 3. Thoughts?

trentm added a commit to trentm/opentelemetry-js-contrib that referenced this issue Feb 14, 2024
…in release-please release PRs

This continues on from open-telemetry#1928. The non-releasing packages are being added to the
release-please manifest in the hope that this prevents them from being listed
in the set of released packages in a release-please PR. This is
effectively Option 1b from open-telemetry#1917.
pichlermarc added a commit that referenced this issue Feb 15, 2024
…in release-please release PRs (#1939)

This continues on from #1928. The non-releasing packages are being added to the
release-please manifest in the hope that this prevents them from being listed
in the set of released packages in a release-please PR. This is
effectively Option 1b from #1917.

Co-authored-by: Marc Pichler <[email protected]>
@pichlermarc
Copy link
Member

@trentm put some thoughts on the PR #1938
Unfortunately it looks like there's no way to do option 1 without release-please being confusing. Option 3 will likely be the better way forward.

trentm added a commit to trentm/opentelemetry-js-contrib that referenced this issue Feb 21, 2024
Because they cause difficulties with updating `@opentelemetry/*` dependencies.
This is "Option 3" from open-telemetry#1917

Refs: open-telemetry#1917
trentm added a commit to trentm/opentelemetry-js-contrib that referenced this issue Feb 21, 2024
pichlermarc pushed a commit that referenced this issue Feb 27, 2024
* chore: remove the non-publishing packages from the npm workspace

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

Refs: #1917

* undo #1917 option 1 work (adding non-publishing packages to release-please config) from #1928

* move express example (haven't adjusted build / docs yet)

* express example updates to get it working

* remove non-publishing packages from release-please manifest

* move koa example

* fix up the koa-example-related files

* move the mongodb/examples files to the top-level

* fixup the mongodb-example files

* move mysql-example files

* fixup the mysql-example files

* move redis-example files to top level examples/ dir

* fixup redis-example files

* update examples README to no longer suggest moving to instruemtnation package dirs

* regenerate package-lock.json to rm the '.../examples' dir entries

'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].

* compile:examples is no longer a thing

* fix for 'npm ci' failures imported from PR #1955

* regenerate package-lock.json

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

* add some more test output information to try to help debug flaky test

* fix tweaks to the test

* undo the instr-perf-hooks test assert tweaks, leaving that to a separate PR
trentm added a commit to trentm/opentelemetry-js-contrib that referenced this issue Feb 28, 2024
trentm added a commit to trentm/opentelemetry-js-contrib that referenced this issue Mar 5, 2024
pichlermarc pushed a commit that referenced this issue Mar 14, 2024
* chore: add script to update '@opentelemetry/*' deps in this repo

Refs: #1917

* add explicit top-level devDeps for modules used by update-otel-deps.js

* updates from Marc's feedback
@trentm
Copy link
Contributor Author

trentm commented Apr 5, 2024

@pichlermarc I think this is good now. Please re-open if there are still problems updating @opentelemetry/* deps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants