Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

fix: support tracing awaited mongoose queries#1007

Merged
kjin merged 1 commit intogoogleapis:masterfrom
kjin:mongoose
Apr 29, 2019
Merged

fix: support tracing awaited mongoose queries#1007
kjin merged 1 commit intogoogleapis:masterfrom
kjin:mongoose

Conversation

@kjin
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

kjin commented Apr 29, 2019

TBR=@ofrobots

Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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