Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: spans started in same async op should be children #1890

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/instrumentation/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ module.exports = Span
util.inherits(Span, GenericSpan)

function Span (transaction, name, ...args) {
var childOf = transaction._agent._instrumentation.activeSpan || transaction
var childOf = transaction._agent._instrumentation.activeSpan ||
transaction._agent._instrumentation.bindingSpan ||
transaction
console.log('XXX new Span: childOf set to',
'activeSpan?', !!transaction._agent._instrumentation.activeSpan,
'bindingSpan?', !!transaction._agent._instrumentation.bindingSpan,
'transaction?', !!transaction,
'childOf.id:', childOf.id)
const opts = typeof args[args.length - 1] === 'object'
? (args.pop() || {})
: {}
Expand Down Expand Up @@ -71,6 +78,7 @@ Span.prototype.end = function (endTime) {

this._timer.end(endTime)
this._agent._instrumentation._recoverTransaction(this.transaction)
this._agent._instrumentation.bindingSpan = null

this.ended = true
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 })
Expand Down