Skip to content

Commit 7169355

Browse files
committed
fix(instrumentations/amqplib): retain parent module context
1 parent 0343b0a commit 7169355

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

lib/instrumentations/amqplib.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var shimmer = require('../utils/shimmer')
2+
var Module = require('module')
23

34
var defaults = require('lodash.defaults')
45
var get = require('lodash.get')
@@ -74,32 +75,32 @@ module.exports = {
7475
instrumentations: [{
7576
path: 'amqplib',
7677
pre: function () {
77-
require('amqplib/channel_api')
78+
Module._load('amqplib/channel_api', arguments[3])
7879
return Array.prototype.slice.call(arguments, 2)
7980
}
8081
}, {
8182
path: 'amqplib/channel_api',
8283
pre: function () {
83-
require('amqplib/lib/channel_model')
84+
Module._load('amqplib/lib/channel_model', arguments[3])
8485
return Array.prototype.slice.call(arguments, 2)
8586
}
8687
}, {
8788
path: 'amqplib/callback_api',
8889
pre: function () {
89-
require('amqplib/lib/callback_model')
90+
Module._load('amqplib/lib/callback_model', arguments[3])
9091
return Array.prototype.slice.call(arguments, 2)
9192
}
9293
}, {
9394
path: 'amqplib/lib/channel_model',
9495
pre: function () {
95-
require('amqplib/lib/connection')
96+
Module._load('amqplib/lib/connection', arguments[3])
9697
return Array.prototype.slice.call(arguments, 2)
9798
},
9899
post: channelModelWrapper
99100
}, {
100101
path: 'amqplib/lib/callback_model',
101102
pre: function () {
102-
require('amqplib/lib/connection')
103+
Module._load('amqplib/lib/connection', arguments[3])
103104
return Array.prototype.slice.call(arguments, 2)
104105
},
105106
post: callbackModelWrapper

0 commit comments

Comments
 (0)