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: support datadog-pprof #411

Closed
wants to merge 2 commits into from

Conversation

austinwoon
Copy link

@austinwoon austinwoon commented Apr 18, 2024

Closes #410

Alternative solution considered

  • Modify the case block used to handle NODE_GYP_BUILD to account for problem identified in Add support for @datadog/pprof #410. This proved to be tricky as we need to retrieve the value from findBindings which involves a walk of the whole tree

Solution

Instead of the alternative above, chose to just add a special case for this package

Automated tests

Just added a conditional testName === '@datadog-pprof' to the foundMatchingBinary statement so we test the presence of the prebuilds folder.

Manual tests (since the automated tests do not test for presence of prebuilds folder

Running node out/cli.js print node_modules/@datadog/pprof/out/src/index.js gives me the following FILELIST

FILELIST:
node_modules/@datadog/pprof/node_modules/node-gyp-build/index.js
node_modules/@datadog/pprof/node_modules/node-gyp-build/package.json
node_modules/@datadog/pprof/node_modules/source-map/lib/array-set.js
node_modules/@datadog/pprof/node_modules/source-map/lib/base64-vlq.js
node_modules/@datadog/pprof/node_modules/source-map/lib/base64.js
node_modules/@datadog/pprof/node_modules/source-map/lib/binary-search.js
node_modules/@datadog/pprof/node_modules/source-map/lib/mapping-list.js
node_modules/@datadog/pprof/node_modules/source-map/lib/mappings.wasm
node_modules/@datadog/pprof/node_modules/source-map/lib/read-wasm.js
node_modules/@datadog/pprof/node_modules/source-map/lib/source-map-consumer.js
node_modules/@datadog/pprof/node_modules/source-map/lib/source-map-generator.js
node_modules/@datadog/pprof/node_modules/source-map/lib/source-node.js
node_modules/@datadog/pprof/node_modules/source-map/lib/util.js
node_modules/@datadog/pprof/node_modules/source-map/lib/wasm.js
node_modules/@datadog/pprof/node_modules/source-map/package.json
node_modules/@datadog/pprof/node_modules/source-map/source-map.js
node_modules/@datadog/pprof/out/src/heap-profiler-bindings.js
node_modules/@datadog/pprof/out/src/heap-profiler.js
node_modules/@datadog/pprof/out/src/index.js
node_modules/@datadog/pprof/out/src/logger.js
node_modules/@datadog/pprof/out/src/profile-encoder.js
node_modules/@datadog/pprof/out/src/profile-serializer.js
node_modules/@datadog/pprof/out/src/sourcemapper/sourcemapper.js
node_modules/@datadog/pprof/out/src/time-profiler-bindings.js
node_modules/@datadog/pprof/out/src/time-profiler.js
node_modules/@datadog/pprof/package.json
node_modules/@datadog/pprof/prebuilds/darwin-arm64/node-102.node
node_modules/@datadog/pprof/prebuilds/darwin-arm64/node-108.node
node_modules/@datadog/pprof/prebuilds/darwin-arm64/node-111.node
node_modules/@datadog/pprof/prebuilds/darwin-arm64/node-115.node
node_modules/@datadog/pprof/prebuilds/darwin-arm64/node-120.node
node_modules/@datadog/pprof/prebuilds/darwin-arm64/node-83.node
node_modules/@datadog/pprof/prebuilds/darwin-arm64/node-88.node
node_modules/@datadog/pprof/prebuilds/darwin-arm64/node-93.node
node_modules/@datadog/pprof/prebuilds/darwin-x64/node-102.node
node_modules/@datadog/pprof/prebuilds/darwin-x64/node-108.node
node_modules/@datadog/pprof/prebuilds/darwin-x64/node-111.node
node_modules/@datadog/pprof/prebuilds/darwin-x64/node-115.node
node_modules/@datadog/pprof/prebuilds/darwin-x64/node-120.node
node_modules/@datadog/pprof/prebuilds/darwin-x64/node-83.node
node_modules/@datadog/pprof/prebuilds/darwin-x64/node-88.node
node_modules/@datadog/pprof/prebuilds/darwin-x64/node-93.node
node_modules/@datadog/pprof/prebuilds/linux-arm64/node-102.node
node_modules/@datadog/pprof/prebuilds/linux-arm64/node-108.node
node_modules/@datadog/pprof/prebuilds/linux-arm64/node-111.node
node_modules/@datadog/pprof/prebuilds/linux-arm64/node-115.node
node_modules/@datadog/pprof/prebuilds/linux-arm64/node-120.node
node_modules/@datadog/pprof/prebuilds/linux-arm64/node-83.node
node_modules/@datadog/pprof/prebuilds/linux-arm64/node-88.node
node_modules/@datadog/pprof/prebuilds/linux-arm64/node-93.node
node_modules/@datadog/pprof/prebuilds/linux-x64/node-102.node
node_modules/@datadog/pprof/prebuilds/linux-x64/node-108.node
node_modules/@datadog/pprof/prebuilds/linux-x64/node-111.node
node_modules/@datadog/pprof/prebuilds/linux-x64/node-115.node
node_modules/@datadog/pprof/prebuilds/linux-x64/node-120.node
node_modules/@datadog/pprof/prebuilds/linux-x64/node-83.node
node_modules/@datadog/pprof/prebuilds/linux-x64/node-88.node
node_modules/@datadog/pprof/prebuilds/linux-x64/node-93.node
node_modules/@datadog/pprof/prebuilds/linuxmusl-x64/node-102.node
node_modules/@datadog/pprof/prebuilds/linuxmusl-x64/node-108.node
node_modules/@datadog/pprof/prebuilds/linuxmusl-x64/node-111.node
node_modules/@datadog/pprof/prebuilds/linuxmusl-x64/node-115.node
node_modules/@datadog/pprof/prebuilds/linuxmusl-x64/node-120.node
node_modules/@datadog/pprof/prebuilds/linuxmusl-x64/node-83.node
node_modules/@datadog/pprof/prebuilds/linuxmusl-x64/node-88.node
node_modules/@datadog/pprof/prebuilds/linuxmusl-x64/node-93.node
node_modules/@datadog/pprof/prebuilds/win32-ia32/node-102.node
node_modules/@datadog/pprof/prebuilds/win32-ia32/node-83.node
node_modules/@datadog/pprof/prebuilds/win32-ia32/node-88.node
node_modules/@datadog/pprof/prebuilds/win32-ia32/node-93.node
node_modules/@datadog/pprof/prebuilds/win32-x64/node-102.node
node_modules/@datadog/pprof/prebuilds/win32-x64/node-108.node
node_modules/@datadog/pprof/prebuilds/win32-x64/node-111.node
node_modules/@datadog/pprof/prebuilds/win32-x64/node-115.node
node_modules/@datadog/pprof/prebuilds/win32-x64/node-120.node
node_modules/@datadog/pprof/prebuilds/win32-x64/node-83.node
node_modules/@datadog/pprof/prebuilds/win32-x64/node-88.node
node_modules/@datadog/pprof/prebuilds/win32-x64/node-93.node
node_modules/delay/index.js
node_modules/delay/package.json
node_modules/p-limit/index.js
node_modules/p-limit/package.json
node_modules/pprof-format/dist/index.js
node_modules/pprof-format/package.json
node_modules/yocto-queue/index.js
node_modules/yocto-queue/package.json

We see that the entire prebuilds folder is correctly included.

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Do you know why prebuilds is not detected?

We fixed this to work with node-gyp-build as well as the fork @aminya/node-gyp-build

I would prefer a fix for the generic case if we can determine what datadog is doing differently here.

@styfle
Copy link
Member

styfle commented Apr 19, 2024

Looks like we're hitting this NODE_GYP_BUILD case correctly, however the AST is not understood and so node-gyp-build is never executed.

case NODE_GYP_BUILD:

@austinwoon
Copy link
Author

austinwoon commented Apr 19, 2024

Looks like we're hitting this NODE_GYP_BUILD case correctly, however the AST is not understood and so node-gyp-build is never executed.

case NODE_GYP_BUILD:

Yes, I described why this was the case in the issue here

Datadog is using a CJS import and assigning it to a variable. So in the AST, we will not be able to infer the package name from the arguments (the arguments are findBinding, .., .. respectively, instead of node-gyp-build, .. or node-gyp-build, .., .. like in the other packages this statement was made for)

I also find that having to manually resolve the arguments via checking the array of args a little hard-codey, so i decided to just have a special case catch all instead for the package to just include prebuilds as it seemed simpler. Hope that makes sense!

@austinwoon
Copy link
Author

Looks like we're hitting this NODE_GYP_BUILD case correctly, however the AST is not understood and so node-gyp-build is never executed.

case NODE_GYP_BUILD:

Could I also check if it would be possible to include a flag to ignore tree shaking modules in a package? I think it would make sense as a catch-all to handle special case like these!

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

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

I think we can revisit the general solution in a new PR and merge this PR once the windows test pass

@austinwoon
Copy link
Author

I think we can revisit the general solution in a new PR and merge this PR once the windows test pass

I have removed the sourcemaps outputs from output.js since there is no actual need to test for those folders. Could you please rerun the test pipeline? Thank you

@styfle
Copy link
Member

styfle commented May 16, 2024

I took a stab at fixing this properly in PR #419

@styfle styfle closed this in #419 May 16, 2024
styfle added a commit that referenced this pull request May 16, 2024
- Fixes #410
- Closes #411

Note, this is easiest to review without whitespace
https://github.com/vercel/nft/pull/419/files?w=1
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.

Add support for @datadog/pprof
2 participants