Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 90 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/instrumentation-mongodb/.tav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ mongodb:
mode: max-7
node: '>=15.0.0'
commands: npm run test-v5-v6
- versions:
include: ">=7 <8"
mode: max-7
node: '>=20.19.0'
commands: npm run test-v7
2 changes: 1 addition & 1 deletion packages/instrumentation-mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-mongodb

### Supported Versions

- [`mongodb`](https://www.npmjs.com/package/mongodb) version `>=3.3.0 <7`
- [`mongodb`](https://www.npmjs.com/package/mongodb) version `>=3.3.0 <8`

## Usage

Expand Down
11 changes: 6 additions & 5 deletions packages/instrumentation-mongodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/instrumentation-mongodb",
"compile": "tsc -p .",
"prepublishOnly": "npm run compile",
"tdd": "npm run test-v5-v6-run -- --watch-extensions ts --watch",
"test": "npm run test-v5-v6 && npm run test-unit",
"tdd": "npm run test-v7 -- --watch-extensions ts --watch",
"test": "npm run test-v7 && npm run test-unit",
Comment on lines +19 to +20
Copy link
Member

Choose a reason for hiding this comment

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

Updating our default MongoDB version / and default tests to v7 means that the contributors will need to update their Node version, right? @david-luna, are there any concerns about it?

"test-unit": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/**/unit/*.test.ts'",
"test-v3": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v3.test.ts'",
"test-v4": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v4.test.ts'",
"test-v5-v6": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'",
"test-v4": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6-v7.metrics.test.ts' 'test/**/mongodb-v4.test.ts'",
"test-v5-v6": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6-v7.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'",
"test-v7": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6-v7.metrics.test.ts' 'test/**/mongodb-v7.test.ts'",
"test:with-services-env": "cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm test",
"test-all-versions": "tav",
"test-all-versions:with-services-env": "cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm run test-all-versions",
Expand Down Expand Up @@ -61,7 +62,7 @@
"@opentelemetry/sdk-trace-base": "^2.0.0",
"@opentelemetry/sdk-trace-node": "^2.0.0",
"@types/bson": "4.0.5",
"mongodb": "6.19.0"
"mongodb": "7.0.0"
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.208.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/instrumentation-mongodb/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class MongoDBInstrumentation extends InstrumentationBase<MongoDBInstrumen
),
new InstrumentationNodeModuleDefinition(
'mongodb',
['>=4.0.0 <7'],
['>=4.0.0 <8'],
undefined,
undefined,
[
Expand All @@ -130,7 +130,7 @@ export class MongoDBInstrumentation extends InstrumentationBase<MongoDBInstrumen
),
new InstrumentationNodeModuleFile(
'mongodb/lib/cmap/connection.js',
['>=6.4.0 <7'],
['>=6.4.0 <8'],
v4PatchConnectionPromise,
v4UnpatchConnection
),
Expand All @@ -142,13 +142,13 @@ export class MongoDBInstrumentation extends InstrumentationBase<MongoDBInstrumen
),
new InstrumentationNodeModuleFile(
'mongodb/lib/cmap/connect.js',
['>=4.0.0 <7'],
['>=4.0.0 <8'],
v4PatchConnect,
v4UnpatchConnect
),
new InstrumentationNodeModuleFile(
'mongodb/lib/sessions.js',
['>=4.0.0 <7'],
['>=4.0.0 <8'],
v4PatchSessions,
v4UnpatchSessions
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const instrumentation = registerInstrumentationTesting(
import { accessCollection, DEFAULT_MONGO_HOST } from './utils';
import type { MongoClient, Collection } from 'mongodb';
import * as assert from 'assert';
import * as semver from 'semver';

async function waitForNumberOfExports(
exporter: InMemoryMetricExporter,
Expand Down Expand Up @@ -77,6 +78,14 @@ describe('MongoDBInstrumentation-Metrics', () => {
shouldTest = false;
}

// MongoDB v7 requires Node.js >= 20.19.0
if (!semver.satisfies(process.version, '>=20.19.0')) {
console.log(
`Skipping mongodb v7 tests. Node.js ${process.version} does not meet minimum requirement of >=20.19.0`
);
shouldTest = false;
}

const HOST = process.env.MONGODB_HOST || DEFAULT_MONGO_HOST;
const PORT = process.env.MONGODB_PORT || 27017;
const DB_NAME = process.env.MONGODB_DB || 'opentelemetry-tests-metrics';
Expand Down
Loading