ref(node): Streamline vendored fs instrumentation#21532
Draft
mydea wants to merge 1 commit into
Draft
Conversation
This streamlines the vendored `fs` instrumentation, following the same approach as the dataloader (#21475) and generic-pool (#21523) refactors: * Use `Sentry.startSpan`/`startInactiveSpan`/`suppressTracing` instead of the OTel tracer APIs * Use the built-in `onlyIfParent` option instead of `requireParentSpan` + a hand-rolled parent check * Remove the unused `createHook`/`endHook`/`requireParentSpan` config and inline the span name, `op`/`origin` and file-path/error attributes directly into the instrumentation * Streamline the types to what we actually need * Remove the `/* eslint-disable */` and make the vendored files pass the (type-aware) linter * Add tests covering the previously-untested option gating While inlining the attribute logic, this also fixes a pre-existing bug: the documented `recordFilePaths` option was never read — file-path span attributes were gated on `recordErrorMessagesAsSpanAttributes` instead. File paths are now gated on `recordFilePaths` and error messages on `recordErrorMessagesAsSpanAttributes`, matching the docs. Closes #20726 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This streamlines the vendored
fsinstrumentation, following the same approach as the dataloader (#21475) and generic-pool (#21523) refactors:Sentry.startSpan/startInactiveSpan/suppressTracinginstead of the OTel tracer APIsonlyIfParentoption instead ofrequireParentSpan+ a hand-rolled parent checkcreateHook/endHook/requireParentSpanconfig and inline the span name,op/originand file-path/error attributes directly into the instrumentation/* eslint-disable */and make the vendored files pass the (type-aware) lintercontext.bindfrom@opentelemetry/apiis kept only for the callback-style functions, where the user's async callback must be restored to the parent context (so it isn't parented to the fs span or caught by tracing suppression) — there is no Sentry equivalent for this.Root cause (drive-by bug fix)
While inlining the attribute logic, this also fixes a pre-existing bug: the documented
recordFilePathsoption was never read — file-path span attributes (path_argument,src_argument, etc.) were gated onrecordErrorMessagesAsSpanAttributesinstead (dates back to the original integration in #13291).File paths are now gated on
recordFilePathsand error messages onrecordErrorMessagesAsSpanAttributes, matching the documented options. New integration tests cover each gate in isolation.Closes #20726