Skip to content
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: fix context loss when cursor are accesed concurrently #1721

Merged

Conversation

david-luna
Copy link
Contributor

Which problem is this PR solving?

This PR is solving the problem of mongodb instrumentation loosing the context when cursors are accessed concurrently.

Short description of the changes

Add a new instrumentation on ConnectionPool class to patch the method that produces the context loss. This class is present from v4 and up so the fix works also for v5

Closes #1688

@david-luna david-luna requested a review from a team as a code owner October 6, 2023 14:31
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 6, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@david-luna
Copy link
Contributor Author

@osherv could you please add your feedback and approval if applies?

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

Merging #1721 (7ef5f65) into main (2502e18) will decrease coverage by 0.14%.
The diff coverage is 20.00%.

❗ Current head 7ef5f65 differs from pull request most recent head 53c9049. Consider uploading reports for the commit 53c9049 to get more accurate results

@@            Coverage Diff             @@
##             main    #1721      +/-   ##
==========================================
- Coverage   91.62%   91.49%   -0.14%     
==========================================
  Files         139      139              
  Lines        7151     7159       +8     
  Branches     1444     1438       -6     
==========================================
- Hits         6552     6550       -2     
- Misses        599      609      +10     
Files Coverage Δ
...etry-instrumentation-mongodb/src/internal-types.ts 100.00% <ø> (ø)
...try-instrumentation-mongodb/src/instrumentation.ts 52.99% <20.00%> (-2.11%) ⬇️

... and 2 files with indirect coverage changes

@pichlermarc pichlermarc added bug Something isn't working priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect pkg:instrumentation-mongodb labels Oct 12, 2023
Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Looks great; thanks for fixing this. 🙂
Edit: looks like this still needs some lint fixes but then this should be good to merge 🙂

Copy link
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

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

LGTM, modulo the linting and typo that Marc mentioned.

FWIW, npm run test-all-versions worked locally for me.

…id-luna/opentelemetry-js-contrib into dluna-1688-mongodb-async-context-fix
@david-luna
Copy link
Contributor Author

Thanks you both for the review :)

@pichlermarc there are some workflows awaiting approval. Are you able to approve them?

@pichlermarc pichlermarc merged commit 1dc2e81 into open-telemetry:main Oct 17, 2023
11 checks passed
@dyladan dyladan mentioned this pull request Oct 17, 2023
@david-luna david-luna deleted the dluna-1688-mongodb-async-context-fix branch October 17, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:instrumentation-mongodb priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mongodb] instrumentation loosing context
4 participants