Skip to content

Commit

Permalink
Refactored pushStack function
Browse files Browse the repository at this point in the history
  • Loading branch information
sromexs committed Mar 8, 2021
1 parent 9e06f82 commit 2eea19e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions packages/next/build/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,14 @@ export function stackPush(compiler: any, spanName: string, attrs?: any): any {
let stack = compilerStacks.get(compiler)
let span

if (!stack) {
compilerStacks.set(compiler, (stack = []))
const fillSpan = () => {
span = tracer.startSpan(spanName, attrs ? attrs() : undefined)
} else {
const parent = stack[stack.length - 1]
if (parent) {
tracer.withSpan(parent, () => {
span = tracer.startSpan(spanName, attrs ? attrs() : undefined)
})
} else {
span = tracer.startSpan(spanName, attrs ? attrs() : undefined)
}
}

!stack && compilerStacks.set(compiler, (stack = []))
const parent = stack[stack.length - 1]
parent ? tracer.withSpan(parent, fillSpan) : fillSpan()

stack.push(span)
return span
}
Expand Down

0 comments on commit 2eea19e

Please sign in to comment.