elastic / elastic/apm-agent-nodejs
Instrumenting Global module
- Dominant language
- JavaScript
- Stars
- 594
- Forks
- 244
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 16
Description
**Is your feature request related to a problem? Please describe.**
I am unable to add instrumentation for Global Objects in the agent in a way that is described [here](https://github.com/elastic/apm-agent-nodejs/issues/312). There are few methods that I needed to instrument like `eval()`, `setTimeout()` etc.
(PS: I don't know if I am approaching this right)
**Describe the solution you'd like**
Instrumentation of Global objects should be either configurable or supported.
**Describe alternatives you've considered**
I have tried adding custom instrumentation by creating a `global.js` file in `lib/instrumentation/modules` and added it to [MODULES](https://github.com/elastic/apm-agent-nodejs/blob/dd20f63cfc56f3078c5e24e56a0f58a2d859a999/lib/instrumentation/index.js#L16) but the agent does not auto instrument this.
**Additional context**
For monkey-patching say eval, I've used shimmer to wrap `global` for eval function.
`shimmer.wrap(global, "eval", wrapEval)`
For reference - https://github.com/elastic/apm-agent-nodejs/issues/312
Contributor guide
Assessment
This issue has not been assessed yet.