diff --git a/lib/instrumentation/module/express.js b/lib/instrumentation/module/express.js index b6b948b7..3a1654eb 100644 --- a/lib/instrumentation/module/express.js +++ b/lib/instrumentation/module/express.js @@ -45,13 +45,6 @@ module.exports = function (agent, version, express) { // } // }) - shimmer.wrap(express.application, 'get', function (original) { - return function () { - const result = original.apply(this, arguments) - return result - } - }) - shimmer.wrap(express.Router, 'use', function (original) { return function () { const result = original.apply(this, arguments) @@ -67,6 +60,8 @@ module.exports = function (agent, version, express) { shimmer.wrap(express.Router, 'route', function (original) { return function () { + const callstack = {} + Error.captureStackTrace(callstack) const result = original.apply(this, arguments) if (this.stack && this.stack.length) { // log.debug('>> [Express] express.Router.route ', this.stack[this.stack.length - 1]) diff --git a/test/instrumentation/module/express.test.js b/test/instrumentation/module/express.test.js index ca89cfc5..8c137fe6 100644 --- a/test/instrumentation/module/express.test.js +++ b/test/instrumentation/module/express.test.js @@ -30,6 +30,16 @@ test(`${testName1} Should record request in basic route`, function (t) { const PATH = '/' + testName const app = new express() + const stackString = `Error + at Function.route (/Users/feelform/workspace/pinpoint/pinpoint-node-agent/lib/instrumentation/module/express.js:64:13) + at Function.app. [as get] (/Users/feelform/workspace/pinpoint/pinpoint-node-agent/node_modules/express/lib/application.js:481:30) + at Test. (/Users/feelform/workspace/pinpoint/pinpoint-node-agent/test/instrumentation/module/express.test.js:33:7) + at Test.bound [as _cb] (/Users/feelform/workspace/pinpoint/pinpoint-node-agent/node_modules/tape/lib/test.js:80:32) + at Test.run (/Users/feelform/workspace/pinpoint/pinpoint-node-agent/node_modules/tape/lib/test.js:96:10) + at Test.bound [as run] (/Users/feelform/workspace/pinpoint/pinpoint-node-agent/node_modules/tape/lib/test.js:80:32) + at Immediate.next [as _onImmediate] (/Users/feelform/workspace/pinpoint/pinpoint-node-agent/node_modules/tape/lib/results.js:83:19) + at processImmediate (internal/timers.js:456:21)` + app.get(PATH, async (req, res) => { Math.random() await util.sleep(3000) @@ -53,7 +63,7 @@ test(`${testName1} Should record request in basic route`, function (t) { server.close() }) }) - +/* const testName2 = 'express2' test(`[${testName2}] Should record request in express.Router`, function (t) { agent.bindHttp() @@ -263,4 +273,4 @@ test(`${testName6} Should record each http method`, function (t) { server.close() }) -}) \ No newline at end of file +})*/ \ No newline at end of file