mongoose icon indicating copy to clipboard operation
mongoose copied to clipboard

Feature: XRay Tracing

Open WiesBen opened this issue 6 years ago • 14 comments

Feature Request:

Would it be possible to integrate XRay Tracing like that: https://github.com/mixmaxhq/mongo-aws-xray

???

Regards

WiesBen avatar Sep 26 '19 09:09 WiesBen

What does this x-ray tracing thing do? The docs don't really have any meaningful examples right now

vkarpov15 avatar Sep 30 '19 00:09 vkarpov15

XRay is a tracing capability for AWS which can then trace any user request from the browser until the result of the database in some kind of service map automatically. See: https://aws.amazon.com/xray/?nc1=h_ls

WiesBen avatar Oct 02 '19 10:10 WiesBen

This may be possible using mongoose middleware, e.g., pre and post hooks.

In theory, it should be possible by overriding $wrapCallback, but in my observation this is not capturing the entire operation.

See https://github.com/mongoosejs/mongoose-async-hooks/issues/8

joebowbeer avatar Oct 03 '19 19:10 joebowbeer

Also see:

https://github.com/googleapis/cloud-trace-nodejs/blob/master/src/plugins/plugin-mongoose.ts

joebowbeer avatar Oct 03 '19 21:10 joebowbeer

This would actually be sufficient, is there an empty plugin template somehow, then I can test it...?

WiesBen avatar Oct 04 '19 09:10 WiesBen

This would be super neat, it would save us having to implement something manually.

Niffy avatar Feb 07 '20 15:02 Niffy

Hey all, I've created the following plugin. Be good to have somebody take a look and give any feedback you may have. The main issue I see is properly correlating the pre and post middleware, especially on insertMany since "this" is the actual model.
https://www.npmjs.com/package/mongoose-xray

eric-swann-q2 avatar May 27 '20 16:05 eric-swann-q2

@eric-swann-q2 I took a quick look and this plugin is very well written :+1: I like how you split up middleware by the 4 types: document, aggregation, query, model.

vkarpov15 avatar Jun 04 '20 18:06 vkarpov15

@vkarpov15 Thanks for your feedback!

eric-swann-q2 avatar Jun 05 '20 20:06 eric-swann-q2

@eric-swann-q2 you rock bro! going to try it now!!!! Thanks, will probably give feedback to or even suggest more changes as hour mongoose thing is not very common.

elribonazo avatar Jun 10 '20 18:06 elribonazo

@eric-swann-q2 awesome work on the mongoose-xray package. I just created a PR to include Service Map support. Happy to discuss the changes directly on the PR https://github.com/unbill/mongoose-xray/pull/5

jmattiace avatar Jul 01 '20 21:07 jmattiace

Oh nice thanks @jmattiace, I'll take a look.

eric-swann-q2 avatar Jul 01 '20 23:07 eric-swann-q2

@jmattiace I've merged in the PR, thanks for the addition!

eric-swann-q2 avatar Jul 02 '20 02:07 eric-swann-q2

If this tracing RFE moves forward, I suggest adding hooks for OpenTelemetry tracing, which is compatible with a number of different consumers, including XRay.

joebowbeer avatar Jan 17 '22 05:01 joebowbeer