Skip to content

Commit c2cb9e7

Browse files
committed
fix(agent): check for the newrelic agent, if present ask the user to require Trace before that
1 parent 48d54bc commit c2cb9e7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ function Trace () {
1515
return
1616
}
1717

18+
// warn the user if the newrelic agent is present as well
19+
if (require.cache.__NR_cache) {
20+
console.error('Make sure to require Trace before New Relic, otherwise Trace won\'t start')
21+
return
22+
}
23+
1824
this.agent = Agent.create({
1925
config: this.config
2026
})

lib/utils/shimmer.js

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ function wrap (nodule, noduleName, methods, wrapper) {
4040
return debug('%s already wrapped by agent.', fqmn)
4141
}
4242

43+
if (original.__NR_original) {
44+
return debug('%s already wrapped the newrelic agent, so it is wrapped by us as well', fqmn)
45+
}
46+
4347
var wrapped = wrapper(original, method)
4448
wrapped.__RS_original = original
4549
wrapped.__RS_unwrap = function __RS_unwrap () {

0 commit comments

Comments
 (0)