From 660e37bb67509b2fdd5cdd814dad2e60aa0ab40b Mon Sep 17 00:00:00 2001 From: David Luna Date: Tue, 28 Nov 2023 20:20:10 +0100 Subject: [PATCH] feat(instrumentation-mongodb): add support for mongodb v6 (#1760) * feat: add support for mongodb v6 * chore: lint fix * chore: revert bump of mongodb * chore: revert test script * chore: revert changelog * chore: filter node versions in TAV * chore: fix .tav.yml --------- Co-authored-by: Daniel Dyla --- .../opentelemetry-instrumentation-mongodb/.tav.yml | 7 +++++-- .../opentelemetry-instrumentation-mongodb/README.md | 2 +- .../opentelemetry-instrumentation-mongodb/package.json | 4 ++-- .../src/instrumentation.ts | 10 +++++----- ...etrics.test.ts => mongodb-v4-v5-v6.metrics.test.ts} | 0 .../test/{mongodb-v5.test.ts => mongodb-v5-v6.test.ts} | 0 6 files changed, 13 insertions(+), 10 deletions(-) rename plugins/node/opentelemetry-instrumentation-mongodb/test/{mongodb-v4-v5.metrics.test.ts => mongodb-v4-v5-v6.metrics.test.ts} (100%) rename plugins/node/opentelemetry-instrumentation-mongodb/test/{mongodb-v5.test.ts => mongodb-v5-v6.test.ts} (100%) diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/.tav.yml b/plugins/node/opentelemetry-instrumentation-mongodb/.tav.yml index 86a2bf927d2..518c012a77f 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/.tav.yml +++ b/plugins/node/opentelemetry-instrumentation-mongodb/.tav.yml @@ -5,7 +5,10 @@ mongodb: - versions: ">=4 <5" commands: npm run test-v4 - versions: ">=5 <6" - commands: npm run test-v5 + commands: npm run test-v5-v6 + - versions: ">=6 <7" + node: '>=15.0.0' + commands: npm run test-v5-v6 # Fix missing `contrib-test-utils` package - pretest: npm run --prefix ../../../ lerna:link + pretest: npm run --prefix ../../../ lerna:link \ No newline at end of file diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/README.md b/plugins/node/opentelemetry-instrumentation-mongodb/README.md index 3ace4bd5951..b6c7c161923 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/README.md +++ b/plugins/node/opentelemetry-instrumentation-mongodb/README.md @@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-mongodb ### Supported Versions -- `>=3.3 <5` +- `>=3.3 <7` ## Usage diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/package.json b/plugins/node/opentelemetry-instrumentation-mongodb/package.json index f5e50569f0b..64a3d848d46 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/package.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/package.json @@ -9,8 +9,8 @@ "docker:start": "docker run -e MONGODB_DB=opentelemetry-tests -e MONGODB_PORT=27017 -e MONGODB_HOST=127.0.0.1 -p 27017:27017 --rm mongo", "test": "npm run test-v3", "test-v3": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v3.test.ts'", - "test-v4": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5.metrics.test.ts' 'test/**/mongodb-v4.test.ts'", - "test-v5": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5.metrics.test.ts' 'test/**/mongodb-v5.test.ts'", + "test-v4": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v4.test.ts'", + "test-v5-v6": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'", "test-all-versions": "tav", "tdd": "npm run test -- --watch-extensions ts --watch", "clean": "rimraf build/*", diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index f44e0df2b28..3be30198484 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -97,31 +97,31 @@ export class MongoDBInstrumentation extends InstrumentationBase { ), new InstrumentationNodeModuleDefinition( 'mongodb', - ['4.*', '5.*'], + ['4.*', '5.*', '6.*'], undefined, undefined, [ new InstrumentationNodeModuleFile( 'mongodb/lib/cmap/connection.js', - ['4.*', '5.*'], + ['4.*', '5.*', '6.*'], v4PatchConnection, v4UnpatchConnection ), new InstrumentationNodeModuleFile( 'mongodb/lib/cmap/connection_pool.js', - ['4.*', '5.*'], + ['4.*', '5.*', '6.*'], v4PatchConnectionPool, v4UnpatchConnectionPool ), new InstrumentationNodeModuleFile( 'mongodb/lib/cmap/connect.js', - ['4.*', '5.*'], + ['4.*', '5.*', '6.*'], v4PatchConnect, v4UnpatchConnect ), new InstrumentationNodeModuleFile( 'mongodb/lib/sessions.js', - ['4.*', '5.*'], + ['4.*', '5.*', '6.*'], v4PatchSessions, v4UnpatchSessions ), diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4-v5.metrics.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4-v5-v6.metrics.test.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4-v5.metrics.test.ts rename to plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4-v5-v6.metrics.test.ts diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5.test.ts rename to plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts