-
Notifications
You must be signed in to change notification settings - Fork 544
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
feat(mongodb4): added mongodb4 instrumentation #794
feat(mongodb4): added mongodb4 instrumentation #794
Conversation
Is there a reason this is a new instrumentation instead of updating the existing mongodb instrumentation? |
I was not suggesting to drop support for v3, but to add support for v4 to the existing instrumentation using a new |
@tydhot Because i think that otel search in one mongodb only |
In most other instrumentations where we patch multiple major versions, we only use the types from the latest version and use |
@dyladan Thanks! ill try! |
Codecov Report
@@ Coverage Diff @@
## main #794 +/- ##
==========================================
- Coverage 95.29% 86.78% -8.52%
==========================================
Files 10 23 +13
Lines 701 1286 +585
Branches 142 260 +118
==========================================
+ Hits 668 1116 +448
- Misses 33 170 +137
|
@dyladan Hey :)
Any idea how to handle with these? Thanks alot |
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.
Looks good! Thanks!
Please remove console.log(getTestSpans());
from mongodb-v3.test.ts
as well.
Some of the small changes(few newlines, typecast to any) could also be taken to v3 test file, but that's not a deal breaker.
plugins/node/opentelemetry-instrumentation-mongodb/package.json
Outdated
Show resolved
Hide resolved
@osherv, please ignore the package in the CI matrix via |
@rauno56 Fixed everything! Thanks a lot for the review :) |
Nice! Even the smallest of my nits now addressed! 👍 I'd love to get another review before we merge. |
plugins/node/opentelemetry-instrumentation-mongodb/src/types.ts
Outdated
Show resolved
Hide resolved
❗ This cannot yet be merged. For some reason, the tests stay pending forever. Works locally. @osherv, the only thing that stands out from the setup is the |
@@ -7,7 +7,8 @@ | |||
"repository": "open-telemetry/opentelemetry-js-contrib", | |||
"scripts": { | |||
"docker:start": "docker run -e MONGODB_DB=opentelemetry-tests -e MONGODB_PORT=27017 -e MONGODB_HOST=localhost -p 27017:27017 --rm mongo", | |||
"test": "nyc ts-mocha --parallel -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'", | |||
"test": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v4.test.ts'", |
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.
this change means we are running PullRequests CI tests only for v4, and stop running v3 tests on PRs.
opentelemetry-js-contrib/package.json
Line 23 in 81b3190
"test:ci:changed": "lerna run test --since origin/main", |
something we might want to consider...
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.
That is correct. I can't think about any other option. Suggestions?
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.
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.
btw, The tests are only can run locally (we need mongodb server). So anyway i dont think i would change much
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.
Yes, I usually spin up a mongo server locally with docker and run the tests against it.
CI tests also start a mongo server here, so the tests can pass.
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.
We talked about this in the SIG. We recommend to test the most popular major version (in this case v3) and test other versions with TAV.
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
|
let commandObj: Record<string, unknown>; | ||
if (command?.documents) { | ||
commandObj = command.documents[0]; | ||
} else if (command.cursors) { |
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.
command?.cursor
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.
Fixed
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Show resolved
Hide resolved
I turned on streaming Lerna output to see that MongoDB tests fail, but do not terminate the process. That's why the tests never finish:
|
Regarding ☝️ That definitely needs to be fixed in two aspects:
|
any update about this PR? I am interested in |
Sry for the delay, i had to omicron virus -_-.. |
Sorry, just wondering. I hope you had a good recovery. Thank you. |
|
|
Good to have you back and thanks for the great work. Hope you are feeling well now :) |
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
|
Thanks for addressing all the comments and for adding the support for v4 🥇 |
Thanks! next pr will be muck more quicker :) |
closing as this PR migrated to #869 due to CLA issues |
MongoDB4 Instrumentation!