diff --git a/lib/instrumentation/hapi.js b/lib/instrumentation/hapi.js index e03e9567a0..9856ecc63a 100644 --- a/lib/instrumentation/hapi.js +++ b/lib/instrumentation/hapi.js @@ -146,6 +146,10 @@ function wrapPreHandlers(shim, container, path) { return _wrapPreHandler(handler) }) } + // The 'pre' option also allows strings pointing to methods registered via + // server.method() (ie: 'methodName(args)'). For the most part, these should + // be simple utility functions, but may be something we want to wrap in the future. + return container function _wrapPreHandler(handler) { return shim.recordMiddleware( diff --git a/test/versioned/hapi/hapi-pre-17/router-v16.tap.js b/test/versioned/hapi/hapi-pre-17/router-v16.tap.js index 9633e36c96..3b731ee378 100644 --- a/test/versioned/hapi/hapi-pre-17/router-v16.tap.js +++ b/test/versioned/hapi/hapi-pre-17/router-v16.tap.js @@ -90,6 +90,11 @@ tap.test('Hapi router introspection', function(t) { t.test('using `pre` config option', function(t) { agent.on('transactionFinished', utils.verifier(t)) + server.method('test', function(arg, next) { + t.ok(agent.getTransaction(), 'transaction available in server method') + next() + }) + var route = { method: 'GET', path: '/test/{id}', @@ -99,6 +104,9 @@ tap.test('Hapi router introspection', function(t) { t.ok(agent.getTransaction(), 'transaction available in plain `pre` function') reply() }, + { + method: 'test' + }, [ { method: function nested(req, reply) { diff --git a/test/versioned/restify/package.json b/test/versioned/restify/package.json index 8683df4771..0ed8d8acb0 100644 --- a/test/versioned/restify/package.json +++ b/test/versioned/restify/package.json @@ -25,7 +25,7 @@ "node": "^0.10" }, "dependencies": { - "restify": ">=5.0.0 <6.3.4 || >6.3.4", + "restify": ">=5.0.0 <6.3.4 || >6.3.4 <7", "express": "4.16" }, "files": [ @@ -41,7 +41,7 @@ "node": ">=0.11.0" }, "dependencies": { - "restify": ">=5.0.0", + "restify": ">=5.0.0 <7", "express": "4.16" }, "files": [