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): fix instrumentation of fs/promises #1375

Merged
merged 12 commits into from
Feb 27, 2023

Conversation

mhassan1
Copy link
Contributor

@mhassan1 mhassan1 commented Feb 6, 2023

Which problem is this PR solving?

This PR fixes @opentelemetry/instrumentation-fs when used with fs/promises.

Short description of the changes

This PR adds logic to @opentelemetry/instrumentation-fs that instruments fs/promises. This will properly instrument fs methods when they come from fs/promises; currently, that instrumentation is not happening.

@mhassan1 mhassan1 requested a review from a team February 6, 2023 16:14
@github-actions github-actions bot requested a review from rauno56 February 6, 2023 16:15
@codecov
Copy link

codecov bot commented Feb 6, 2023

Codecov Report

Merging #1375 (1080abc) into main (e93a192) will increase coverage by 2.14%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1375      +/-   ##
==========================================
+ Coverage   96.06%   98.21%   +2.14%     
==========================================
  Files          14        1      -13     
  Lines         890       56     -834     
  Branches      192        4     -188     
==========================================
- Hits          855       55     -800     
+ Misses         35        1      -34     
Impacted Files Coverage Δ
...emetry-propagator-instana/src/InstanaPropagator.ts
...erator-aws-xray/src/internal/xray-id-generation.ts
...entation-document-load/src/enums/AttributeNames.ts
...etry-plugin-react-load/src/enums/AttributeNames.ts
...lemetry-instrumentation-document-load/src/utils.ts
...metry-propagator-ot-trace/src/OTTracePropagator.ts
...metry-propagator-aws-xray/src/AWSXRayPropagator.ts
...lugin-react-load/src/BaseOpenTelemetryComponent.ts
...etapackages/auto-instrumentations-web/src/utils.ts
...strumentation-document-load/src/instrumentation.ts
... and 5 more

@blumamir
Copy link
Member

I just merged #1332 and it seems to create conflicts in this PR, sorry about that

plugins/node/instrumentation-fs/test/fsPromises.test.ts Outdated Show resolved Hide resolved
plugins/node/instrumentation-fs/test/fsPromises.test.ts Outdated Show resolved Hide resolved
spans
) => {
const rootSpanName = `${name} test span`;
it(`promises.${name} ${error ? 'error' : 'success'}`, async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I'm missing something, but isn't this test already exist in the file 'fs.test.ts' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is testing fs/promises, whereas fs.test.ts is testing fs.promises.

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.

Looks like this is just applying the existing patch from fs.promises and adding tests. Looks good to me

Comment on lines +59 to +62
init(): (
| InstrumentationNodeModuleDefinition<FS>
| InstrumentationNodeModuleDefinition<FSPromises>
)[] {
Copy link
Member

Choose a reason for hiding this comment

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

nit: i think this type is more explicit

Suggested change
init(): (
| InstrumentationNodeModuleDefinition<FS>
| InstrumentationNodeModuleDefinition<FSPromises>
)[] {
init(): [InstrumentationNodeModuleDefinition<FS>, InstrumentationNodeModuleDefinition<FSPromises>] {

Comment on lines +31 to +32
const supportsPromises =
parseInt(process.versions.node.split('.')[0], 10) >= 14;
Copy link
Member

Choose a reason for hiding this comment

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

The repo supports node >= 14 anyway, so I guess this is not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved by #1413

@haddasbronfman haddasbronfman merged commit 3ca874e into open-telemetry:main Feb 27, 2023
haddasbronfman added a commit that referenced this pull request Feb 27, 2023
@dyladan dyladan mentioned this pull request Feb 27, 2023
@haddasbronfman
Copy link
Member

Sorry, I merged this PR but now I see there is still a comment about it: #1375 (comment). If you want to address this comment, I suggest to do it on another PR.

@mhassan1
Copy link
Contributor Author

@haddasbronfman #1375 (comment) will be addressed in #1413.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants