Glimpse / Home

Project Glimpse: Node Edition - Spend less time debugging and more time developing.
http://node.getglimpse.com
Other
252 stars 9 forks source link

Support being initialized after imports #111

Closed atrauzzi closed 7 years ago

atrauzzi commented 7 years ago

Fully acknowledging the way things are currently done with the node edition, I suggest that Glimpse be able to function without having to be initialized prior to subsequent imports (express, hapi, etc).

Specific to my own case, this has caused a bit of an issue with my application framework lifecycle which uses a dependency injection system and is service provider based. If I want to integrate glimpse's logging output or any current and future features, I'm likely going to want to resolve those contracts from my IoC.

If this requires that glimpse be explicitly told what server implementations it's clamping around during init, I'd consider that a reasonable compromise to get an alternative to the automatic-on behaviour.

Additionally - and I'm not 100% of an expert on this next one - I suspect the requirement of being initialized before other modules are loaded could interfere with any tools that attempt to optimize or build by reading module imports.

philliphoff commented 7 years ago

Can you be a little more specific, @atrauzzi, about how you think Glimpse might interfere with the use of an IoC? Even with an IoC, there should still be a single entry point from which Glimpse can be require()'d and initialized. After that point, it shouldn't matter how/when other component's packages are require()'d as Glimpse instruments packages lazily.

(The reason Glimpse must be initialized first is so that it can setup a hook to listen for other packages being imported, at which point it will add the appropriate instrumentation. If your application doesn't (explicitly or implicitly) import a package that Glimpse instruments, instrumentation of that package will not occur.)

atrauzzi commented 7 years ago

My original thought was to do with module hoisting, optimization and just making sure no code has to be run before the module graph is complete.

This may or may not be an issue, but might merit consideration as the init call is a statement.

philliphoff commented 7 years ago

Feel free to give Glimpse a try in such a project and let us know if you run into any issues, as we definitely want Glimpse to work in as many scenarios as possible. Otherwise, if you can point to a project with an IoC similar to yours, we can experiment with adding Glimpse to the project ourselves and see how it behaves.

atrauzzi commented 7 years ago

I think I'll be able to deliver that in a little bit. I'll close this ticket now and return later if possible with a repo link.