Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to instrument files that are not an npm package #1973

Closed
bizob2828 opened this issue Jan 25, 2024 · 1 comment · Fixed by #1974
Closed

Unable to instrument files that are not an npm package #1973

bizob2828 opened this issue Jan 25, 2024 · 1 comment · Fixed by #1974
Assignees
Labels

Comments

@bizob2828
Copy link
Member

Description

Prior to v11.0.0 of the agent, you could use the API instrument, instrumentMessages, etc to instrument any file. The moduleName had to be the first time the package is required. In v11.0.0 we switched to use require-in-the-middle to instrument CommonJS modules.

In the v11.0.0 changelog we did call out: "You can no longer instrument files that are not within a node_module unless you provide an absolute path to the file when registering the instrumentation." However, that's not entirely possible.

Expected Behavior

Provide ability to instrument a file that's not within a 3rd party package.

You should see this in the output of repro app

[NEWRELIC] instrumenting nifty-messages
[NEWRELIC] instrumenting method 'publish'
[NEWRELIC] instrumenting method 'purge'
[NEWRELIC] instrumenting callbacks of method 'getMessage'
[NEWRELIC] instrumenting callbacks of method 'subscribe'

Steps to Reproduce

  1. Clone this repo
  2. Follow readme but upgrade to latest agent npm i newrelic@latest
  3. Run npm start

Additional context

This probably doesn't affect any customers. It just makes it easier for us to show how to use the instrument API methods by building some contrived "module" but have it live within the application.

@bizob2828 bizob2828 added the bug label Jan 25, 2024
@workato-integration
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment