-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mongodb): add support for mongodb v4, v5 & mongoose v6 & v7
- Loading branch information
Showing
12 changed files
with
39,757 additions
and
34,725 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,8 +155,12 @@ | |
"mocha-junit-reporter": "^2.0.2", | ||
"mocha-multi-reporters": "^1.5.1", | ||
"mock-require": "3.0.3", | ||
"mongodb": "^3.6.9", | ||
"mongodb": "^5.4.0", | ||
"mongodb-v3": "npm:mongodb@^3.7.3", | ||
"mongodb-v4": "npm:mongodb@^4.16.0", | ||
"mongoose": "^7.1.0", | ||
"mongoose-v5": "npm:[email protected]", | ||
"mongoose-v6": "npm:[email protected]", | ||
"morgan": "^1.10.0", | ||
"mssql": "^9.0.1", | ||
"mssql-v8": "npm:mssql@^8.1.4", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/collector/test/tracing/database/mongodb/mockVersion.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* (c) Copyright IBM Corp. 2023 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const mock = require('mock-require'); | ||
const requireHook = require('../../../../../core/src/util/requireHook'); | ||
|
||
const MONGODB_VERSION = process.env.MONGODB_VERSION; | ||
const MONGODB_REQUIRE = process.env.MONGODB_VERSION === 'latest' ? 'mongodb' : `mongodb-${MONGODB_VERSION}`; | ||
|
||
if (MONGODB_REQUIRE !== 'mongodb') { | ||
mock('mongodb', MONGODB_REQUIRE); | ||
} | ||
|
||
const originalOnFileLoad = requireHook.onFileLoad; | ||
requireHook.onFileLoad = function onFileLoad() { | ||
if ( | ||
arguments[0].source === '\\/mongodb\\/lib\\/cmap\\/connection\\.js' || | ||
arguments[0].source === '\\/mongodb\\/lib\\/core\\/connection\\/pool\\.js' | ||
) { | ||
const str = arguments[0].source.replace('mongodb', MONGODB_REQUIRE); | ||
const reg = new RegExp(str, ''); | ||
arguments[0] = reg; | ||
return originalOnFileLoad.apply(this, arguments); | ||
} | ||
|
||
return originalOnFileLoad.apply(this, arguments); | ||
}; |
Oops, something went wrong.