Skip to content

Commit

Permalink
fix invalid parent index on segment reset
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev committed May 7, 2024
1 parent 00072ed commit 39e4e9f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/dd-trace/src/collector/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DatadogCollectorSpan extends DatadogSpan {

spanContext._spanIndex = trace.lastIndex++

if (fields.parent) {
if (parent && trace.segmentId === parent.segmentId) {
spanContext._parentIndex = parent._spanIndex >= 0
? parent._spanIndex + 1
: 0
Expand Down Expand Up @@ -98,14 +98,16 @@ class DatadogCollectorSpan extends DatadogSpan {
} else {
const traceId = spanContext._traceId
const parentId = spanContext._parentId
const time = trace.startTime
const time = trace.startTime // TODO: update time on new segment

trace.active = 1
trace.lastIndex = 0
trace.segmentId = ++segmentId

startSegmentChannel.publish({ parentId, segmentId, time, traceId })
}

spanContext.segmentId = trace.segmentId
}

_initContext (props) {
Expand Down

0 comments on commit 39e4e9f

Please sign in to comment.