Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions packages/node/src/integrations/fs/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { defineIntegration } from '@sentry/core';
import { generateInstrumentOnce } from '@sentry/node-core';
import { FsInstrumentation } from './vendored/instrumentation';
import { enableFsInstrumentation } from './vendored/instrumentation';

const INTEGRATION_NAME = 'FileSystem';

let _isEnabled = false;

/**
* This integration will create spans for `fs` API operations, like reading and writing files.
*
Expand All @@ -16,6 +17,11 @@ const INTEGRATION_NAME = 'FileSystem';
export const fsIntegration = defineIntegration(
(
options: {
Comment thread
timfish marked this conversation as resolved.
Outdated
/**
* Whether to enable the plugin.
* @default true
*/
enabled?: boolean;
/**
* Setting this option to `true` will include any filepath arguments from your `fs` API calls as span attributes.
*
Expand All @@ -34,14 +40,10 @@ export const fsIntegration = defineIntegration(
return {
name: INTEGRATION_NAME,
setupOnce() {
generateInstrumentOnce(
INTEGRATION_NAME,
() =>
new FsInstrumentation({
recordFilePaths: options.recordFilePaths,
recordErrorMessagesAsSpanAttributes: options.recordErrorMessagesAsSpanAttributes,
}),
)();
if (options.enabled === false) return;

@nicohrubec nicohrubec Jun 22, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

m: Do we need to expose an enabled flag? Afaik we don't have such a flag for other instrumentations and not sure if we need it given that the integration needs to be explicitly added

@timfish timfish Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah, because I removed InstrumentationConfig I assumed we needed to retain the enabled to make the change non-breaking but it wasn't exported!

if (_isEnabled) return;
_isEnabled = true;
Comment thread
timfish marked this conversation as resolved.
Outdated
enableFsInstrumentation(options);
},
};
},
Expand Down
Loading
Loading