elastic / elastic/apm-agent-nodejs

could we log.warn if `require.cache` already has modules we typically instrument at `agent.start()` time?

Open
#2,578 4 comments 0 reactions 0 assignees View on GitHub
8.10-candidate 8.12-candidate agent-nodejs
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

A reasonably common mistake when using the APM agent is to `.start()` it *after* having `require()`d some modules that the agent *would* have instrumented. We could probably look through `require.cache` at `Agent#start()`-time to see if it already had imported modules that the agent *would* have instrumented (modulo `active` and `disableInstrumentations`), and if so, then emit a `log.warn('yo, you need to apm.start() earlier')`. Then that log message could be in the troubleshooting docs to explain the issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.