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

fix: Refactored wrapper to load and wrap handler early #187

Merged
merged 15 commits into from
Nov 28, 2023

Conversation

mrickard
Copy link
Member

This PR refactors the Node wrapper file and updates tests. A previous PR introduced support for no-code-change instrumentation of ESM functions, but handled CJS functions asynchronously, which was not compatible with callback-returning Lambda functions. A later PR resolved that issue, but deferred wrapping the user's Lambda handler until invocation time. This PR wraps handlers on load rather than on invocation, and preserves a synchronous path for CJS functions along with an asynchronous path for ESM functions.

Signed-off-by: mrickard <[email protected]>
…g wrapping before applying args

Signed-off-by: mrickard <[email protected]>
…ndler definition in a function to be called in tests.

Signed-off-by: mrickard <[email protected]>
…state unit test files. Restructured ESM unit tests to inspect errors from failures in the wrapping/import phase

Signed-off-by: mrickard <[email protected]>
Copy link

@jsumners-nr jsumners-nr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: it seems this is being handled in some other way. Disregard this request.

Can we update the following lines to include npm install --production?:

npm install --prefix $BUILD_DIR newrelic@latest

npm install --prefix $BUILD_DIR newrelic@latest

npm install --prefix $BUILD_DIR newrelic@latest

npm install --prefix $BUILD_DIR newrelic@latest

@mrickard mrickard requested a review from jsumners-nr November 27, 2023 20:52
Copy link

@jsumners-nr jsumners-nr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing I have enough context to comment on is some effective globals in the tests, but I wouldn't block for that. Overall, it looks good to me.

Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall it looks good. One question but nice work refactoring this 👏🏻


t.test('should wrap handler in transaction', async(t) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a unit test for lambda in cjs with callback or are we just relying on the integration tests for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're relying on integration tests with the functions that return callbacks. For those, the issue hasn't been loss of instrumentation, but an interruption in the return value, so we test that explicitly for the callback-returning functions.

@mrickard mrickard merged commit 9a96826 into master Nov 28, 2023
7 checks passed
@jsumners-nr jsumners-nr deleted the NR-180866/performance-one-wrapper-file branch November 29, 2023 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants