Skip to content

Commit 6c30661

Browse files
committed
fix: spans started in same async op should be children
This commit is just a start. There are still tests and discussion to be had. Fixes #1889
1 parent 3838ea6 commit 6c30661

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/instrumentation/span.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ module.exports = Span
1717
util.inherits(Span, GenericSpan)
1818

1919
function Span (transaction, name, ...args) {
20-
var childOf = transaction._agent._instrumentation.activeSpan || transaction
20+
var childOf = transaction._agent._instrumentation.activeSpan ||
21+
transaction._agent._instrumentation.bindingSpan ||
22+
transaction
23+
console.log('XXX new Span: childOf set to',
24+
'activeSpan?', !!transaction._agent._instrumentation.activeSpan,
25+
'bindingSpan?', !!transaction._agent._instrumentation.bindingSpan,
26+
'transaction?', !!transaction,
27+
'childOf.id:', childOf.id)
2128
const opts = typeof args[args.length - 1] === 'object'
2229
? (args.pop() || {})
2330
: {}
@@ -71,6 +78,7 @@ Span.prototype.end = function (endTime) {
7178

7279
this._timer.end(endTime)
7380
this._agent._instrumentation._recoverTransaction(this.transaction)
81+
this._agent._instrumentation.bindingSpan = null
7482

7583
this.ended = true
7684
this._agent.logger.debug('ended span %o', { span: this.id, parent: this.parentId, trace: this.traceId, name: this.name, type: this.type, subtype: this.subtype, action: this.action })

0 commit comments

Comments
 (0)