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

feat: implement auto-instrumentation for fs #872

Merged
merged 42 commits into from
Mar 8, 2022

Conversation

rauno56
Copy link
Member

@rauno56 rauno56 commented Feb 9, 2022

Which problem is this PR solving?

This implements partial auto-instrumentation for the native fs module.

Short description of the changes

This instruments most of the fs functions. Full list in constants.ts file.
Provides two hooks:

  • createHook: (functionName: string, info: { args: ArrayLike<unknown> }) => boolean;
  • endHook: (functionName: string, info: { args: ArrayLike<unknown>; span: api.Span }) => void;

Returning false from createHook skips creating the trace.

Checklist

  • Ran npm run test-all-versions for the edited package(s) on the latest commit if applicable.

@codecov
Copy link

codecov bot commented Feb 9, 2022

Codecov Report

Merging #872 (ab5cf69) into main (982843d) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #872   +/-   ##
=======================================
  Coverage   95.91%   95.91%           
=======================================
  Files          13       13           
  Lines         856      856           
  Branches      178      178           
=======================================
  Hits          821      821           
  Misses         35       35           

@rauno56 rauno56 changed the title feat: initial patching of the fs sync and cb based functions feat: implement auto-instrumentation for fs Feb 14, 2022
@rauno56 rauno56 force-pushed the feat/instrumentation-fs branch 3 times, most recently from d70e735 to ca4c3ea Compare February 17, 2022 08:28
@rauno56 rauno56 marked this pull request as ready for review February 17, 2022 09:26
@rauno56 rauno56 requested a review from a team February 17, 2022 09:26
@rauno56 rauno56 marked this pull request as draft February 17, 2022 17:06
@rauno56 rauno56 force-pushed the feat/instrumentation-fs branch from d4d4ed8 to ec00508 Compare February 18, 2022 14:00
@rauno56 rauno56 marked this pull request as ready for review February 18, 2022 14:00
@vmarchaud vmarchaud requested a review from a team February 19, 2022 09:31
plugins/node/instrumentation-fs/package.json Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/package.json Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/index.ts Show resolved Hide resolved
plugins/node/instrumentation-fs/package.json Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/package.json 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/test/index.test.ts Outdated Show resolved Hide resolved
@rauno56
Copy link
Member Author

rauno56 commented Feb 22, 2022

Thanks a lot @vmarchaud and @blumamir. Really valuable feedback! I addressed everything in one way or another and took the liberty to resolve all the threads I found trivial and resolved.

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

I'll let you decide on the suppressing. I'm going to approve, but not merge until you've made that decision.

@@ -0,0 +1,67 @@
{
"name": "@opentelemetry/instrumentation-fs",
"version": "0.27.0",
Copy link
Member

Choose a reason for hiding this comment

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

Why starting at version 27?

Copy link
Member Author

Choose a reason for hiding this comment

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

Out of a habit. We used to version-match packages. I guess it can now be 0.1.0, which makes a lot more sense.

plugins/node/instrumentation-fs/package.json Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/src/instrumentation.ts Outdated Show resolved Hide resolved
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.

LGTM, great work. Was waiting for instrumentation for this package, thanks for taking it 🤩

@dyladan
Copy link
Member

dyladan commented Mar 2, 2022

@rauno56 you can merge this if you're happy with it. I think with release-please updated we should no longer need to manually add it to the manifest.

@rauno56
Copy link
Member Author

rauno56 commented Mar 3, 2022

Hard to go back the other way without breaking alerts and stuff.

I think that's a good point. I'll change that to be strict for now. I'll convert the PR to draft since I will be fixing this next week.

Note to myself: test to make sure user calls in callbacks aren't suppressed.

@rauno56 rauno56 marked this pull request as draft March 3, 2022 07:11
@rauno56 rauno56 marked this pull request as ready for review March 8, 2022 10:31
@rauno56 rauno56 merged commit c3fa161 into open-telemetry:main Mar 8, 2022
@rauno56 rauno56 deleted the feat/instrumentation-fs branch March 8, 2022 13:45
@dyladan dyladan mentioned this pull request Mar 9, 2022
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.

5 participants