-
Notifications
You must be signed in to change notification settings - Fork 538
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
fix(mongodb): mongodb
v6.4.0 & 6.5.0 support
#2001
fix(mongodb): mongodb
v6.4.0 & 6.5.0 support
#2001
Conversation
@@ -353,7 +353,12 @@ export class MongoDBInstrumentation extends InstrumentationBase { | |||
instrumentation.setPoolName(options); | |||
callback(err, conn); | |||
}; | |||
return original.call(this, options, patchedCallback); | |||
|
|||
const result = original.call(this, options, patchedCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels slightly messy to be passing in this patchedCallback
that isn't going to be used.
Thoughts on a separate patch function for mongodb >=6.4.0 -- this one would just do the promise thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my intention was to not split the patch logic of this function to 2 separate patches. I do agree is not optimal to create a function that may not be used. I'll try to come with a different approach
@@ -58,7 +58,7 @@ | |||
"@types/mongodb": "3.6.20", | |||
"@types/node": "18.6.5", | |||
"mocha": "7.2.0", | |||
"mongodb": "3.6.11", | |||
"mongodb": "^6.4.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is done, then the default "test"
script will need to change above, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right
} | ||
|
||
const result = original.call(this, ns, cmd, options, patchedCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar Q to above: would separate patch functions (one that uses the callback, one that uses the promise) be clearer? or would they just be a pain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the patchedCallback
can be reused because basically the API change has been to "promisify" the function. A separate patch is not complicated, it's almost an identical copy.
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Show resolved
Hide resolved
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2001 +/- ##
==========================================
- Coverage 90.97% 90.63% -0.34%
==========================================
Files 146 146
Lines 7492 7488 -4
Branches 1502 1494 -8
==========================================
- Hits 6816 6787 -29
- Misses 676 701 +25
|
@trentm I did the split you suggested but partially. I think it was overkill to split the logic of the Now I'm hitting a problem in if I log the version under test... --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts
+++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts
@@ -56,6 +56,9 @@ describe('MongoDBInstrumentation-Tracing-v4', () => {
const COLLECTION_NAME = 'test-traces';
const URL = `mongodb://${HOST}:${PORT}/${DB_NAME}`;
+ const version = require('mongodb/package.json').version;
+ console.log(`testing mongodb@${version}`);
+
let client: mongodb.MongoClient;
let collection: mongodb.Collection; it turns out we get a different version for testing > @opentelemetry/[email protected] 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'
testing [email protected]
MongoDBInstrumentation-Metrics
✓ Should add connection usage metrics (101ms)
✓ Should add disconnection usage metrics (213ms)
MongoDBInstrumentation-Tracing-v4
Instrumenting query operations
1) "before each" hook: mongoBeforeEach for "should create a child span for insert"
2) "after each" hook for "should create a child span for insert"
2 passing (4s)
2 failing
.... @trentm I think you got into a similar situation but I can't find the issue or PR. Do you recall having a similar issue? 🤔 |
mongodb
v6.4.0 supportmongodb
v6.4.0 & 6.5.0 support
Yup, it was described here: #1938 (comment)
The looking for any npm install felt it didn't need to install v4.17.1 locally:
Yuck. This has to be an npm bug. I'm not sure how to cope with this in general. |
…telemetry-js-contrib into 1983-mongodb-6-4-support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for humouring me on the splitting the callback vs. promise patching. That looks like it a was a fair amount of extra work.
LGTM, though I think the .tav.yml update should be added before merge.
.github/workflows/unit-test.yml
Outdated
@@ -11,7 +11,7 @@ jobs: | |||
matrix: | |||
node: ["14", "16", "18.18.2"] | |||
include: | |||
- node: 14 | |||
- node: 16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: This was discussion in the OTel JS SIG this week as a fix for the code-coverage check failures. Testing coverage only with node v14 artificially results in coverage looking poor for a unit-test run that skips all or most tests for the (now old) node v14.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this 🙂
plugins/node/opentelemetry-instrumentation-mongodb/package.json
Outdated
Show resolved
Hide resolved
Co-authored-by: Marc Pichler <[email protected]>
So the split added new code that isn't covered by the tests since is meant to run in earlier versions. I'll see what I can do about it |
By looking at the docs there is no way to tell @pichlermarc do you think is okay to move forward and have a follow-up PR about merging coverage reports from unit testing? |
I agree dealing with merging of coverage reports is out of scope for this PR. |
Which problem is this PR solving?
the new version of mongodb
v6.4.0
comes with some internal changes that break the instrumentation. Drtails of the changes are described in #1983 (comment)Closes: #1983
Short description of the changes
patches of the changed methods have been refactored to accept both implementations
<6.4.0
>=6.4.0