-
Notifications
You must be signed in to change notification settings - Fork 45
Usage of Loader hook as APM/RASP vendors #508
Description
I did not find a similar issue but let me know if this is a duplicate.
I build and maintain a RASP tool (basically a security APM) that relies on dynamic instrumentation:
When a module is loaded through require
, I keep a reference on it so I can later monkeypatch some methods from this module.
(In some cases, I have to fallback on a more regular APM case where I monkeypatch methods when the module is loaded because it's not possible to do otherwise, but for performances reasons, delayed monkeypatching is the best solution for my use case).
I believe such thing should still be possible with the current implementation of loader hooks (let me know if I am missing something).
However, there are two points regarding which I could not wrap my head around to see how my module would fit with loader hooks:
Multiple APMs
It is pretty usual for my customers to use my module along with a regular APM. Currently, the APM
and the RASP intercept somehow the same things in the require
internals and most of the time it works well (when it does not we fix our own code to be reliable over the impact of the other module and we quickly message the maintainer to let them know).
With loader hooks, having multiple instrumentation tools seems complicated. Is there a guideline on how to do that?
How would you recommend we ensure that a vendor does not becomes exclusive and prevents anyone else from instrumenting the same process?
UX
Currently, APMs and RASPs can be instanciated by doing require('<APM or RASP>')
as the first line of executed code (or the second one if the users has another instrumentation tool). An alternative is to use the -r
flag when starting the node
process.
This is a pretty great UX for users right now as they have the choice to either commit some code that will enable the module or update the starting script. Depending of the internal organisation of the teams, installing the module falls in the hands of the dev or the ops people. This flexibility is very useful as sometimes we have to deal with interal tensions within the users' orgs and offering an alternative shows itself useful.
Would there be any chance to imagine a dev-based way of instanciating a loader hook?
Bottomline
I believe the first of this two concerns is pretty critical before ES modules can be considered as stable: this could lose customers to some instrumentation companies!
I am sure I can find some time to work in the next few months on this if needed (that would postpone Audit Hooks (1) (2) but that's probably acceptable).