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
970 stars 125 forks source link

Allow trace probe to instrument functions of any number of params #620

Closed mattcolegate closed 4 years ago

mattcolegate commented 4 years ago

Fix for issue #601

The function for returning trace-enabled functions for functions with over 9 arguments (the 'default' case for generateF) was not returning anything usable. During testing I discovered that using a function with no arguments returned the same trace data as using a function with a specified number of arguments. It seems node doesn't care how many arguments you pass a function unless specific arguments are used in the body of the function, which we're not doing - we're just passing the entire arguments list. Therefore a single function with no parameters takes care of all cases.

Tested by writing a sample web app which calls a module function with 5 args that was traced, and confirmed that exactly the same trace data came back using the generateF 5 arg function, and the no-arg function.