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: support tracing awaited mongoose queries #1007

Merged
merged 1 commit into from
Apr 29, 2019
Merged

Conversation

kjin
Copy link
Contributor

@kjin kjin commented Apr 29, 2019

Fixes #1000

The problem occurs because Query#exec (which makes the MongoDB API call) occurs within the body of a userspace then call, which has no context when awaited. To remedy this, we patch new Query objects so that exec has the same context as where the Query was created. This assumes that we want context at the API call to be the same as the place where Query was constructed. As much (if not all) of the Mongoose read APIs create and execute the Query objects in a single function call, I believe this to be a safe assumption.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 29, 2019
@kjin kjin marked this pull request as ready for review April 29, 2019 17:51
@kjin kjin requested a review from a team April 29, 2019 17:51
@kjin kjin force-pushed the mongoose branch 2 times, most recently from 9abe524 to 103d856 Compare April 29, 2019 17:57
@kjin kjin merged commit deb2a44 into googleapis:master Apr 29, 2019
@kjin
Copy link
Contributor Author

kjin commented Apr 29, 2019

TBR=@ofrobots

Copy link
Contributor

@ofrobots ofrobots left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Awaited Mongoose queries are not traced
4 participants