Skip to content

Commit

Permalink
fix: fix https tracing breakage in node <9 and rewrite http tests (#717)
Browse files Browse the repository at this point in the history
PR-URL: #717
  • Loading branch information
kjin authored Apr 5, 2018
1 parent c66b041 commit a3ea16d
Show file tree
Hide file tree
Showing 5 changed files with 397 additions and 343 deletions.
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export const defaultConfig = {
'hapi': path.join(pluginDirectory, 'plugin-hapi.js'),
'http': path.join(pluginDirectory, 'plugin-http.js'),
'http2': path.join(pluginDirectory, 'plugin-http2.js'),
'https': path.join(pluginDirectory, 'plugin-https.js'),
'knex': path.join(pluginDirectory, 'plugin-knex.js'),
'koa': path.join(pluginDirectory, 'plugin-koa.js'),
'mongodb-core': path.join(pluginDirectory, 'plugin-mongodb-core.js'),
Expand Down
10 changes: 9 additions & 1 deletion src/plugins/plugin-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ function patchHttp(http: HttpModule, api: TraceAgent) {
}
}

// https.get depends on https.request in <8.9 and >=8.9.1
// https.get depends on Node http internals in 8.9.0 and 9+ instead of the
// public http module.
function patchHttps(https: HttpsModule, api: TraceAgent) {
shimmer.wrap(https, 'request', (request) => {
return makeRequestTrace('https:', request, api);
Expand Down Expand Up @@ -215,6 +216,13 @@ const plugin: Plugin = [
patch: patchHttp,
unpatch: unpatchHttp,
},
{
file: 'https',
versions: '<8.9.0 || ^8.9.1',
// require http if it wasn't patched yet, because the https client uses
// the public 'http' module.
patch: () => require('http')
},
{
file: 'https',
versions: '=8.9.0 || >=9.0.0',
Expand Down
21 changes: 0 additions & 21 deletions src/plugins/plugin-https.ts

This file was deleted.

Loading

0 comments on commit a3ea16d

Please sign in to comment.