Skip to content

Commit

Permalink
Change to duck-type check for http emitters.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmacnaughton committed Jun 8, 2018
1 parent ccec9a6 commit 9544c4c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,13 +522,9 @@ exports.bind = function (fn) {
exports.bindEmitter = function (em) {
try {
if (em && typeof em.on === 'function') {
// allow binding if tracing or an http emitter. no last event has been setup
// when the http instrumentation binds the events.
if (exports.tracing
|| (clsCheck()
&& (em instanceof http.IncomingMessage || em instanceof http.ServerResponse)
)
) {
// allow binding if tracing or an http emitter (duck-typing check). no last event
// has been setup when the http instrumentation binds the events.
if (exports.tracing || (clsCheck() && (em.headers && em.socket))) {
return exports.requestStore.bindEmitter(em)
}
}
Expand Down

0 comments on commit 9544c4c

Please sign in to comment.