Skip to content

Commit 14420cb

Browse files
committed
Add logs to debug in ubuntu
1 parent cc6ca80 commit 14420cb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/datadog-instrumentations/src/fs.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,13 @@ function createWrapFunction (prefix = '', override = '') {
259259
const operation = name.match(/^(.+?)(Sync)?(\.native)?$/)[1]
260260

261261
return function () {
262-
if (!startChannel.hasSubscribers) return original.apply(this, arguments)
263-
262+
console.log(`wrapFunction => function(): name: ${name}, method: ${method}, operation: ${operation}`)
263+
console.log('startChannel._stores', startChannel._stores)
264+
if (!startChannel.hasSubscribers) {
265+
console.log(`NO SUBSCRIBERS - name: ${name}, method: ${method}, operation: ${operation}`)
266+
return original.apply(this, arguments)
267+
}
268+
console.log(`HAS_SUBSCRIBERS - name: ${name}, method: ${method}, operation: ${operation}`)
264269
const lastIndex = arguments.length - 1
265270
const cb = typeof arguments[lastIndex] === 'function' && arguments[lastIndex]
266271
const params = getMethodParamsRelationByPrefix(prefix)[operation]
@@ -272,6 +277,7 @@ function createWrapFunction (prefix = '', override = '') {
272277
ctx.error = error
273278
errorChannel.publish(ctx)
274279
}
280+
console.log('finishChannel.runStores(ctx, cb)')
275281
return finishChannel.runStores(ctx, cb)
276282
}
277283

@@ -282,6 +288,7 @@ function createWrapFunction (prefix = '', override = '') {
282288
}
283289

284290
return startChannel.runStores(ctx, () => {
291+
console.log(`startChannel.runStores: name: ${name}, method: ${method}, operation: ${operation}`)
285292
if (abortController.signal.aborted) {
286293
const error = abortController.signal.reason || new Error('Aborted')
287294

@@ -319,7 +326,7 @@ function createWrapFunction (prefix = '', override = '') {
319326
}
320327
)
321328
}
322-
329+
console.log('finishChannel.runStores(ctx, () => {}): L324')
323330
finishChannel.runStores(ctx, () => {})
324331

325332
return result

packages/dd-trace/test/appsec/rasp/fs-plugin.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ describe('AppsecFsPlugin', () => {
237237
storage('legacy').enterWith(origStore)
238238

239239
opFinishCh.subscribe(onFinish)
240+
console.log('BEFORE - fs.readFileSync')
240241

241242
fs.readFileSync(path.join(__dirname, 'fs-plugin.spec.js'))
242243

244+
console.log('AFTER - fs.readFileSync')
243245
assert.strictEqual(count, 0)
244246
} finally {
245247
opFinishCh.unsubscribe(onFinish)

0 commit comments

Comments
 (0)