Skip to content

Commit

Permalink
use spanId as parentSpanId
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Dec 30, 2024
1 parent 05e8010 commit 2be2129
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/otel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,18 @@ function mapLogRecord(logRecord: ILogRecord): ISpan {
attributes.push({ key: 'log_body', value: logRecord.body })
}
}
let { traceId, spanId } = logRecord
let { traceId, spanId: parentSpanId } = logRecord
if (!traceId || traceId.length === 0) {
traceId = generateRand(16)
}
if (!spanId || spanId.length === 0) {
spanId = generateRand(8)
if (parentSpanId && parentSpanId.length === 0) {
parentSpanId = null
}

return {
traceId,
spanId,
spanId: generateRand(8),
parentSpanId,
startTimeUnixNano: time,
endTimeUnixNano: time,
attributes,
Expand Down

0 comments on commit 2be2129

Please sign in to comment.