diff --git a/plugins/node/instrumentation-fs/src/constants.ts b/plugins/node/instrumentation-fs/src/constants.ts index 4b2a8ac0fc..e003949180 100644 --- a/plugins/node/instrumentation-fs/src/constants.ts +++ b/plugins/node/instrumentation-fs/src/constants.ts @@ -67,6 +67,7 @@ export const CALLBACK_FUNCTIONS: FMember[] = [ 'readFile', 'readlink', 'realpath', + ['realpath', 'native'], 'rename', 'rm', // added in v14 'rmdir', @@ -111,6 +112,7 @@ export const SYNC_FUNCTIONS: FMember[] = [ 'readFileSync', 'readlinkSync', 'realpathSync', + ['realpathSync', 'native'], 'renameSync', 'rmdirSync', 'rmSync', // added in v14 diff --git a/plugins/node/instrumentation-fs/test/index.test.ts b/plugins/node/instrumentation-fs/test/index.test.ts index cb49a5f5d0..bf0fc7e7c9 100644 --- a/plugins/node/instrumentation-fs/test/index.test.ts +++ b/plugins/node/instrumentation-fs/test/index.test.ts @@ -28,6 +28,8 @@ import * as sinon from 'sinon'; import type * as FSType from 'fs'; import tests, { TestCase, TestCreator } from './definitions'; import type { FMember, FPMember, CreateHook, EndHook } from '../src/types'; +import { SYNC_FUNCTIONS } from '../src/constants'; +import * as fsActual from 'fs' const supportsPromises = parseInt(process.versions.node.split('.')[0], 10) > 8; @@ -260,6 +262,23 @@ describe('fs instrumentation', () => { }); }; + describe('Syncronous API native', () => { + beforeEach(() => { + plugin.enable(); + }); + it('should not remove fs functions', () => { + console.log(fsActual) + for (const fname of SYNC_FUNCTIONS) { + if(Array.isArray(fname)) { + let [K, L] = fname + assert.strictEqual(typeof (fsActual[K] as any)[L], 'function', `fs.${K}.${L} is not a function`); + } else { + assert.strictEqual(typeof fsActual[fname], 'function', `fs.${fname} is not a function`); + } + } + }) + }) + describe('Syncronous API', () => { const selection: TestCase[] = tests.filter( ([, , , , options = {}]) => options.sync !== false