Skip to content

Commit

Permalink
#86 expectedStackString
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed May 27, 2021
1 parent 4e389f2 commit 5e0cbea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 2 additions & 7 deletions lib/instrumentation/module/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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])
Expand Down
14 changes: 12 additions & 2 deletions test/instrumentation/module/express.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<computed> [as get] (/Users/feelform/workspace/pinpoint/pinpoint-node-agent/node_modules/express/lib/application.js:481:30)
at Test.<anonymous> (/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)
Expand All @@ -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()
Expand Down Expand Up @@ -263,4 +273,4 @@ test(`${testName6} Should record each http method`, function (t) {
server.close()
})
})
})*/

0 comments on commit 5e0cbea

Please sign in to comment.