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(instrumentation-fs): allow realpath.native and realpathSync.native #1332

Merged
merged 17 commits into from
Feb 16, 2023

Conversation

JakubKoralewski
Copy link
Contributor

Hi! First PR here 🎅 Let me know if I did something wrong.

Which problem is this PR solving?

Fixes #1315

Short description of the changes

Maybe I overengineered it a little by adding ['realpath', 'native'], and ['realpathSync', 'native'] to CALLBACK_FUNCTIONS and SYNC_FUNCTIONS respectively, instead of just adding if statements, but I guess it's future-proof. The crux of the matter is the call to Object.assign(rv, original); that assigns properties from the original function onto the new one, the native property gets assigned, but the function specific stuff is read-only so the function itself doesn't get overwritten.

@JakubKoralewski JakubKoralewski requested a review from a team December 17, 2022 20:40
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 17, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: JakubKoralewski / name: Jakub Koralewski (7c4c533, e13cfc0)

@JakubKoralewski JakubKoralewski changed the title test(instrumentation-fs): allow realpath.native and realpathSync.native fix(instrumentation-fs): allow realpath.native and realpathSync.native Dec 17, 2022
@github-actions github-actions bot requested a review from rauno56 December 17, 2022 20:40
@weyert
Copy link

weyert commented Dec 21, 2022

Will this also fix the issue with using `fs/promises?

@JakubKoralewski
Copy link
Contributor Author

No, sorry

Copy link
Member

@blumamir blumamir 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 working on this fix.
Added a few comments, mainly about style and types.

plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/types.ts Show resolved Hide resolved
plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
change indexFs return types and object properties of return
previously ['realpath', 'native'] now 'realpath.native'

also moved exported yet private functions to utils file

fixed tests to follow these changes

refactored patching code to function with added comment
@JakubKoralewski
Copy link
Contributor Author

@blumamir sorry for the delay, I tried to address all your suggestions let me know if I missed anything

@blumamir
Copy link
Member

blumamir commented Feb 8, 2023

Hi @JakubKoralewski , I apologize for the this PR is open.
Thank you so much for addressing the comments.

Would it be possible for you to jump on a quick zoom call to discuss this? I searched for your name in CNCF slack but couldn't find you there.

plugins/node/instrumentation-fs/src/utils.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/utils.ts Outdated Show resolved Hide resolved
…trib into fix-realpathsync-native

# Conflicts:
#	plugins/node/instrumentation-fs/src/instrumentation.ts
#	plugins/node/instrumentation-fs/src/types.ts
@blumamir
Copy link
Member

@JakubKoralewski please fix the CI and I'll merge

@codecov
Copy link

codecov bot commented Feb 12, 2023

Codecov Report

Merging #1332 (fbf40fa) into main (3484b75) will increase coverage by 0.12%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1332      +/-   ##
==========================================
+ Coverage   96.08%   96.21%   +0.12%     
==========================================
  Files          14       15       +1     
  Lines         895      951      +56     
  Branches      192      196       +4     
==========================================
+ Hits          860      915      +55     
- Misses         35       36       +1     
Impacted Files Coverage Δ
...tapackages/auto-instrumentations-node/src/utils.ts 98.21% <0.00%> (ø)

@blumamir
Copy link
Member

@JakubKoralewski - I pushed a few commits to your branch to attempt to fix the build and lint issues. Please take a look and approve if you are ok with them

@blumamir blumamir merged commit ee0a59a into open-telemetry:main Feb 16, 2023
@dyladan dyladan mentioned this pull request Feb 16, 2023
mhassan1 added a commit to mhassan1/opentelemetry-js-contrib that referenced this pull request Feb 17, 2023
Abinet18 pushed a commit to Abinet18/opentelemetry-js-contrib that referenced this pull request Feb 25, 2023
open-telemetry#1332)

* test(instrumentation-fs): add failing test for bug

* fix(instrumentation-fs): allow .native fs funcs

* refactor(instrumentation-fs): indexFs

change indexFs return types and object properties of return

* refactor(instr-fs): use string for two level fns

previously ['realpath', 'native'] now 'realpath.native'

also moved exported yet private functions to utils file

fixed tests to follow these changes

refactored patching code to function with added comment

* refactor(instrumentation-fs): remove memberToDisplayName

* refactor(instrumentation-fs): simplify splitTwoLevels signature

* fix(instrumentation-fs): lint

* fix(instrumentation-fs): lint (typeof fs)

* fix(instrumentation-fs): test types

* chore: fix compile and lint

* fix(fs): exclude undefined in generic type

* test(fs): skip fs functions in node14 which were added later

---------

Co-authored-by: Amir Blum <amirgiraffe@gmail.com>
Co-authored-by: Amir Blum <amir@aspecto.io>
haddasbronfman added a commit that referenced this pull request Feb 27, 2023
* fix(instrumentation-fs): fix instrumentation of `fs/promises`

* Revert "fix(instrumentation-fs): fix instrumentation of `fs/promises`"

This reverts commit 90d9f0d.

* fix(instrumentation-fs): fix instrumentation of `fs/promises`

* chore(instrumentation-fs): fix lint error

* chore(instrumentation-fs): hard-code `R_OK` value for node 14

* chore(instrumentation-fs): fix supported version for `fs/promises`

* chore(instrumentation-fs): incorporate changes from #1332

* chore(instrumentation-fs): consolidate common test utilities

---------

Co-authored-by: Haddas Bronfman <85441461+haddasbronfman@users.noreply.github.com>
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.

@opentelemetry/instrumentation-fs: Node service crashes when 'native' function property is used
4 participants