Skip to content

Conversation

@trentm
Copy link
Contributor

@trentm trentm commented Jun 26, 2025

This PR builds on Amir's #2878 (the instr-redis consolidation).

summary of diffs to Amir's

  • I've changed the testing so that npm test just tests against the version of redis currently installed and npm run test-all-versions handles testing against older versions of redis. (See my argument for this in a section below. commit 8a52338)
  • I've renamed src/instrumentation.ts to src/redis.ts just to have a name change. This allows git to notice that src/instrumentation.ts was moved to src/v2-v3/instrumentation.ts. This makes for a smaller, clearer diff and **clearer history tracking with git log --follow ... later. (commit 9b0fc9e)
  • I've removed all the sources in the old instrumentation-redis-4 for the same reason: git notices the move of src/... and test/... files to the new location. (commit 79cd098)
  • Drop DEFAULT_CONFIG handling in src/v4/instrumentation.ts, which I believe is no longer necessary (commit f46e166). Amir's PR had already dropped the DEFAULT_CONFIG handling for src/v2-v3/instrumentation.ts.
  • Remove instrumentation-redis-4 from auto-instrumentations-node and release-please: necessary given that I removed the package. (commit d2fa3a2) I'm not sure if this is a "breaking" change for auto-instrumentations-node. It certainly is something we should point out in the changelog / PR description.

why the test changes

I moved all testing against redis v2 and v3 to npm run test-all-versions. Testing against older versions of the target module is what test-all-versions is for.

This, then, makes npm test only test against the currently installed version of the module being instrumented (redis v4). IMO this is what npm test should be doing in all our packages. npm test should not change the versions of things installed, which is what happens in Amir's PR (note the "invalid" version in npm ls after running npm test):

% npm test
...

% npm ls redis
[email protected] /Users/trentm/tm/opentelemetry-js-contrib7
└─┬ @opentelemetry/[email protected] -> ./plugins/node/opentelemetry-instrumentation-redis
  └── [email protected] invalid: "3.1.2" from plugins/node/opentelemetry-instrumentation-redis

One current exception (the only one?) to this is the instrumentation-mongodb tests. Testing of multiple versions of mongodb was added to npm test in #2681 to help with coverage numbers. A better answer is to get coverage data from test-all-version runs. @david-luna is working on this. (Note that the testing of mongodb@3 was dropped from npm test as a workaround for flaky tests a while back: #2757 (comment))

With my changes in this PR, to do local dev testing against redis@3, one would need to:

npm run test:docker:run
npm install --no-save redis@3 # or whatever specific version
RUN_REDIS_TESTS=1 npm run test-v2-v3

I think this is reasonable. There will be vanishly little dev on the legacy v2-v3 instrumentation.

follow-ups

If we go with this PR and once it is released:

@trentm trentm marked this pull request as draft June 26, 2025 22:41
@trentm
Copy link
Contributor Author

trentm commented Jun 26, 2025

Moved back to draft, because I need to cope with redisTypes usage in test/v2-v3/redis.test.ts now that the currently installed redis is no longer redis@3, so the types cause a npm run compile failure.

@trentm
Copy link
Contributor Author

trentm commented Jun 26, 2025

Grrr, why can I not do this? (This is a rhetorical question.)

% npm run compile

> @opentelemetry/[email protected] compile
> tsc -p .

src/v2-v3/utils.ts:17:34 - error TS6137: Cannot import type declaration files. Consider importing 'redis' instead of '@types/redis'.

17 import type * as redisTypes from '@types/redis';
                                    ~~~~~~~~~~~~~~

test/v2-v3/redis.test.ts:46:44 - error TS6137: Cannot import type declaration files. Consider importing 'redis' instead of '@types/redis'.

46 import type { RedisClient, Callback } from '@types/redis';
                                              ~~~~~~~~~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  src/v2-v3/utils.ts:17
     1  test/v2-v3/redis.test.ts:46

Copy link
Contributor

@david-luna david-luna left a comment

Choose a reason for hiding this comment

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

I prefer this testing approach since is more aligned to the improvements I'm planning to do in #2866

My only concern would be how we could lure users to this consolidated instrumentation so they don't get stuck into the last version of @opentelemetry/instrumentation-redis-4. How many time will pass until users notice they haven't been updating in a while and go check the README? Could we be more "noisy" about this change?

@david-luna
Copy link
Contributor

and thanks to @blumamir & @trentm for working on this :)

@trentm
Copy link
Contributor Author

trentm commented Jun 27, 2025

Could we be more "noisy" about this change?

One of the followup tasks is to set npm deprecate ... on the old package name. IIUC, every npm install ... done by users will get a warning that it is deprecated. We can set a message that will be shown there to point users to the consolidated package.

Copy link
Member

@blumamir blumamir left a comment

Choose a reason for hiding this comment

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

That looks great @trentm thank you for bringing it to the finish line 💯

@blumamir blumamir changed the title feat(instrumentation-redis)!: consolidate redis v2,3 and redis v4 instrumentation to one package (alternative to Amir's) feat(instrumentation-redis)!: consolidate redis v2,3 and redis v4 instrumentation to one package Jul 2, 2025
@blumamir
Copy link
Member

blumamir commented Jul 2, 2025

we should also remove redis-4 from the component owner also

@blumamir
Copy link
Member

blumamir commented Jul 2, 2025

and here :)

@github-actions github-actions bot added pkg:instrumentation-ioredis pkg:redis-common pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found. labels Jul 2, 2025
@trentm trentm merged commit 5988c79 into open-telemetry:main Jul 2, 2025
22 of 23 checks passed
@trentm trentm deleted the trentm-redis-consolidation-alt branch July 2, 2025 21:46
@dyladan dyladan mentioned this pull request Jul 2, 2025
trentm added a commit to trentm/opentelemetry.io that referenced this pull request Jul 9, 2025
It was merged into the `@opentelemetry/instrumentation-redis` package
(as of version 0.50.0), which already has an entry here.
See the deprecation notice at https://www.npmjs.com/package/@opentelemetry/instrumentation-redis-4

Refs: open-telemetry/opentelemetry-js-contrib#2915
@trentm
Copy link
Contributor Author

trentm commented Jul 9, 2025

The "follow-ups" are complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:auto-instrumentations-node pkg:instrumentation-ioredis pkg:instrumentation-redis pkg:redis-common pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants