RuntimeTools / appmetrics

Node Application Metrics provides a foundational infrastructure for collecting resource and performance monitoring data for Node.js-based applications.
https://developer.ibm.com/open/node-application-metrics/
Apache License 2.0
978 stars 127 forks source link

Use of Node Sync API #556

Closed gustavomassa closed 3 years ago

gustavomassa commented 5 years ago

Hello,

I've noticed that appmetrics internally uses the node sync API on the aspect.js file. It seems that it is using the fs sync functions, it would be easy to change to fs async api. Using the sync API could impact negatively on the event loop.

Sync functions being used:

(node:58060) WARNING: Detected use of sync API

    at fs.openSync (fs.js:646:18)

    at fs.readFileSync (fs.js:551:33)

    at Module._extensions..js (module.js:662:20)

    at Module.load (module.js:565:32)

    at tryModuleLoad (module.js:505:12)

    at Module._load (module.js:497:3)

    at Module.require (module.js:596:17)

    at newFunc (C:\Projetos\Webbuffet\node_modules\appmetrics\lib\aspect.js:101:26)

    at require (internal/module.js:11:18)

(node:58060) WARNING: Detected use of sync API

    at tryStatSync (fs.js:517:13)

    at fs.readFileSync (fs.js:553:3)

    at Module._extensions..js (module.js:662:20)

    at Module.load (module.js:565:32)

    at tryModuleLoad (module.js:505:12)

    at Module._load (module.js:497:3)

    at Module.require (module.js:596:17)

    at newFunc (C:\Projetos\Webbuffet\node_modules\appmetrics\lib\aspect.js:101:26)

    at require (internal/module.js:11:18)

(node:58060) WARNING: Detected use of sync API

    at fs.readSync (fs.js:675:18)

    at tryReadSync (fs.js:540:20)

    at fs.readFileSync (fs.js:575:19)

    at Module._extensions..js (module.js:662:20)

    at Module.load (module.js:565:32)

    at tryModuleLoad (module.js:505:12)

    at Module._load (module.js:497:3)

    at Module.require (module.js:596:17)

    at newFunc (C:\Projetos\Webbuffet\node_modules\appmetrics\lib\aspect.js:101:26)

(node:58060) WARNING: Detected use of sync API

    at fs.closeSync (fs.js:612:18)

    at C:\Projetos\Webbuffet\node_modules\graceful-fs\graceful-fs.js:51:27

    at fs.readFileSync (fs.js:592:8)

    at Module._extensions..js (module.js:662:20)

    at Module.load (module.js:565:32)

    at tryModuleLoad (module.js:505:12)

    at Module._load (module.js:497:3)

    at Module.require (module.js:596:17)

    at newFunc (C:\Projetos\Webbuffet\node_modules\appmetrics\lib\aspect.js:101:26)

(node:58060) WARNING: Detected use of sync API

    at realpathSync (fs.js:1617:13)

    at toRealPath (module.js:164:13)

    at tryFile (module.js:160:22)

    at tryExtensions (module.js:172:22)

    at Module._findPath (module.js:225:20)

    at Module._resolveFilename (module.js:545:25)

    at Module._load (module.js:474:25)

    at Module.require (module.js:596:17)

    at newFunc (C:\Projetos\Webbuffet\node_modules\appmetrics\lib\aspect.js:101:26)