diff --git a/packages/datadog-plugin-hapi/src/index.js b/packages/datadog-plugin-hapi/src/index.js index 9231a7bfc30..751beadf109 100644 --- a/packages/datadog-plugin-hapi/src/index.js +++ b/packages/datadog-plugin-hapi/src/index.js @@ -49,6 +49,17 @@ function createWrapDispatch (tracer, config) { } module.exports = [ + { + name: '@hapi/hapi', + versions: ['>=17.9'], + file: 'lib/request.js', + patch (Request, tracer, config) { + this.wrap(Request, 'generate', createWrapGenerate(tracer, config)) + }, + unpatch (Request) { + this.unwrap(Request, 'generate') + } + }, { name: 'hapi', versions: ['>=17.1'], @@ -82,6 +93,17 @@ module.exports = [ this.unwrap(Request.prototype, '_execute') } }, + { + name: '@hapi/hapi', + versions: ['>=17.9'], + file: 'lib/core.js', + patch (Core, tracer, config) { + this.wrap(Core.prototype, '_dispatch', createWrapDispatch(tracer, config)) + }, + unpatch (Core) { + this.unwrap(Core.prototype, '_dispatch') + } + }, { name: 'hapi', versions: ['7.2 - 16'], diff --git a/packages/datadog-plugin-hapi/test/index.spec.js b/packages/datadog-plugin-hapi/test/index.spec.js index 8ab0f2ccf56..c523e0ac2b8 100644 --- a/packages/datadog-plugin-hapi/test/index.spec.js +++ b/packages/datadog-plugin-hapi/test/index.spec.js @@ -16,7 +16,7 @@ describe('Plugin', () => { let handler describe('hapi', () => { - withVersions(plugin, 'hapi', version => { + withVersions(plugin, ['hapi', '@hapi/hapi'], (version, module) => { beforeEach(() => { tracer = require('../../dd-trace') handler = (request, h, body) => h.response ? h.response(body) : h(body) @@ -29,7 +29,7 @@ describe('Plugin', () => { before(() => { return agent.load(plugin, 'hapi') .then(() => { - Hapi = require(`../../../versions/hapi@${version}`).get() + Hapi = require(`../../../versions/${module}@${version}`).get() }) })