-
Notifications
You must be signed in to change notification settings - Fork 227
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, docs: support mongoose >=5.7.0 <7 #2547
Conversation
Using the For example with [email protected] I see:
However with [email protected]:
And with mongoose@6:
Where is the ".find" span? Is there a bug in our instrumentation or is |
Ah, actually, if I change the script above to:
Now I get a
I don't think it is the Mongoose client caching a write and avoiding hitting the DB. Perhaps it is some pipelining or bulk query or transaction where that ".insert" is actually doing the find query as well? Seems unlikely. There is still something going on in the DB client I don't understand. |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
User request for this at https://discuss.elastic.co/t/support-for-mongoose-version-5-7/305849 |
I am confused why Is there a flag or something that needs to be enabled? |
@aniketbiprojit Some history:
It looks to me like instrumentation of mongoose versions after v5.7.0 is working, at least partially. |
I am not seeing any instrumentation response in requests/trace from I had to create a plugin to use targetSchema.pre(/.*/, preQueryHook);
targetSchema.post(/.*/, postQueryHook);
function preQueryHook() {
if (this.op === undefined) {
return;
}
this.__span = apmAgent.startSpan(
`${target.op} on ${target._collection?.collectionName
} with filter: ${JSON.stringify(
target._conditions ?? {},
undefined,
4,
)}`,
);
const span = this.__span as apm.Span | undefined;
if (span) {
span.addLabels({
filter: JSON.stringify(target._conditions ?? {}, undefined, 4),
update: JSON.stringify(target._update ?? {}, undefined, 4),
projection: JSON.stringify(
target._userProvidedFields ?? {}
),
});
span.setType('db', 'MongoDB', target.op);
}
}
function postQueryHook() {
if (this.__span) {
this.__span.end();
}
} |
Starting with mongoose 5.7.0, it uses "mongodb" (rather than "mongodb-core") as a backend.
2db939a
to
d79ba4b
Compare
This was handled in #3653 |
Starting with mongoose 5.7.0, it uses "mongodb" (rather than
"mongodb-core") as a backend.
Checklist